CPP Inputs & Outputs
CPP Inputs & Outputs
Input:
Enter an integer: 1234
Output:
Sum of digits: 10
Product of digits: 24
2. Reverse a Number
Input:
Enter a number: 1234
Output:
Reversed number: 4321
Input:
Enter the number of terms (n): 4
Output:
Sum of the series: 2.08333
Input:
Enter the number of terms (n): 5
Output:
Sum of the series: 3
Input:
Enter a string: radar
Output:
The string is a palindrome.
Input 1:
Enter a number: 23
Output 1:
23 is a prime number.
Output 2:
Prime numbers less than 100:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
7. Factors of a Number
Input:
Enter a number: 12
Output:
Factors of 12 are: 1 2 3 4 6 12
Input:
Enter two numbers: 5 10
Output:
Before swapping: x = 5, y = 10
After swapping: x = 10, y = 5
Input:
Enter the number of lines: 3
Output:
***
*****
Input:
Enter the number of elements: 5
Enter the elements: 1 2 2 3 4
Output:
Even elements: 2 2 4
Odd elements: 1 3
Sum: 12, Average: 2.4
Max: 4, Min: 1
Array without duplicates: 1 2 3 4
Array in reverse order: 4 3 2 1
Input:
(Provided as command-line arguments: Hello World)
Output:
Occurrences of each alphabet:
d: 1, e: 1, h: 1, l: 3, o: 2, r: 1, w: 1
Input:
Enter two numbers: 6 9
Output:
Before swapping: x = 6, y = 9
After swapping: x = 9, y = 6
Input:
Enter two numbers: 7 8
Output:
Before alteration: x = 7, y = 8
After alteration: x = 17, y = 16
Input:
Enter the radius of the circle: 5
Output:
Area: 78.53975, Circumference: 31.4159
Input:
Enter the number of elements: 3
Enter the elements: 1 2 3
Output:
Sum of elements: 6
16. Merge Two Sorted Arrays
Input:
Enter the size of the first array: 3
Enter the sorted elements of the first array: 1 3 5
Enter the size of the second array: 3
Enter the sorted elements of the second array: 2 4 6
Output:
Merged sorted array: 1 2 3 4 5 6
Input:
Enter the number of terms: 6
Output (Iteration):
Fibonacci series (Iteration): 0 1 1 2 3 5
Output (Recursion):
Fibonacci series (Recursion): 0 1 1 2 3 5
Input:
Enter a number: 5
Output (Iteration):
Factorial (Iteration): 120
Output (Recursion):
Factorial (Recursion): 120
Input:
Enter two numbers: 24 36
Output (Iteration):
GCD (Iteration): 12
Output (Recursion):
GCD (Recursion): 12
Made by Atul