C++ Codes - Basic to Advanced 💻
Open in Telegram
💡 Daily C++ Codes with Output & Logic Any queries, message 👉 @sai7981 🤖 Get instant code explanations: @cpp_codes_bot 🔗 Join now: @cpp_code_snippets #cpp #dsa #coding #programming
Show more3 188
Subscribers
No data24 hours
+357 days
+12030 days
Posts Archive
🔥🔥Be Active Tonight❣️🔥
Big Billion Days Pre Sale Live at 12 Tonight.
GRAB Many Products at Sale Price Before Sale
Click Here and Stay Tuned in the Channel 👇
https://t.me/student_accessories_deals
Note : Link Will Be open in Night Stay Tuned😍😍
hello friends amazon and flipkart sales are going to be started very soon
for best deals in best prices join our deals channel and grab best deals👇
https://t.me/student_accessories_deals
Hurry Up! join fast!
C PROGRAMMING LANGUAGE 💻:
https://docs.google.com/forms/d/e/1FAIpQLScJTzmc6K94aL0LQxxaLp_mN5jlcBWc8QJ0S_ZNGXDX13tSJQ/viewform?usp=sf_link
☝️☝️☝️☝️☝️
friends everyone fill the above form so that i can know what to post in the channel
💢I request everyone to fill the form 💢
https://t.me/flipkart_myntra_ajio_meeshodeals
☝️☝️☝️☝️☝️☝️
Students accessories like laptops , mobiles, earbuds, keyboard ,mouse ,smart watches etc.. are posted here
💢 Join fast and grab 💢
//Write a program to reverse the elements of an array
public class ArrayReversal {
public static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
// Reverse the array in-place.
for (int i = 0; i < numbers.length / 2; i++) {
int temp = numbers[i];
numbers[i] = numbers[numbers.length - 1 - i];
numbers[numbers.length - 1 - i] = temp;
}
System.out.print("Reversed array: ");
for (int number : numbers) {
System.out.print(number + " ");
}
}
}
//Generate and display a series of random numbers within a specified range.
import java.util.Random;
public class RandomNumberGenerator {
public static void main(String[] args) {
int min = 1; // Minimum value of the range
int max = 100; // Maximum value of the range
int numberOfRandoms = 5; // Number of random numbers to generate
Random random = new Random();
System.out.println("Random numbers within the range [" + min + ", " + max + "]:");
for (int i = 0; i < numberOfRandoms; i++) {
int randomNumber = random.nextInt(max - min + 1) + min;
System.out.println(randomNumber);
}
}
}
//Calculate the sum of the digits of a positive integer
import java.util.Scanner;
public class SumOfDigits {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a positive integer: ");
int number = scanner.nextInt();
int sum = 0;
// Calculate the sum of digits using a loop.
while (number > 0) {
sum += number % 10; // Add the last digit to the sum.
number /= 10; // Remove the last digit from the number.
}
System.out.println("Sum of digits: " + sum);
}
}
//Calculate the area of a triangle given its base and height.
import java.util.Scanner;
public class TriangleAreaCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the base of the triangle: ");
double base = scanner.nextDouble();
System.out.print("Enter the height of the triangle: ");
double height = scanner.nextDouble();
double area = 0.5 * base * height;
System.out.println("The area of the triangle is: " + area);
}
}
//Convert a decimal number to its binary representation
import java.util.Scanner;
public class DecimalToBinary {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a decimal number: ");
int decimal = scanner.nextInt();
String binary = Integer.toBinaryString(decimal);
System.out.println("Binary representation: " + binary);
}
}
//Calculate the factorial of a given number using recursion
public class RecursiveFactorial {
public static void main(String[] args) {
int number = 5; // Change this to the desired number
long factorial = calculateFactorial(number);
System.out.println("Factorial of " + number + " is: " + factorial);
}
// Recursive function to calculate the factorial.
private static long calculateFactorial(int n) {
if (n == 0) {
return 1;
}
return n * calculateFactorial(n - 1);
}
}
