1. Write a C++ program to check two numbers are equal or not.
Solution:

Output – 1:
Enter 2 numbers: 12 12
Numbers are equal
Output – 2:
Enter 2 numbers: 23 45
Numbers are not equal
2. Write a program to find the greater number among two numbers.
Solution:

OR

Output:
Enter 2 numbers: 23 56
Greater number is: 56
3. Write a program to check whether a number is even or odd.
Solution:

Output – 1:
Enter a number: 4
4 is even number
Output – 2:
Enter a number: 7
7 is odd number
4. Write a program to check whether a year is leap year or not.
Solution:

Output – 1:
Enter a year: 2020
2020 is leap year
Output – 1:
Enter a year: 2025
2025 is not leap year
5. Write a C++ program to find the largest number among three numbers.
Solution:

Output:
Enter 3 numbers: 10 20 30
Largest number is: 30
6. Write a C++ program to check whether a character is vowel or not using switch case.
Solution:

Output – 1:
Enter any character: A
A is a vowel
Output – 2:
Enter any character: r
r is not a vowel
7. Write a program in C++ to display the name of the day in a week.
Solution:

Output – 1:
Enter a number between 1 to 7: 5
Thursday
Output – 2:
Enter a number between 1 to 7: 10
Invalid Number
8. Write a C++ program to make a simple calculator to add, subtract, multiply and divide using switch case.
Solution:

Output – 1:
Enter 2 number: 10 20
Enter an operator (+, -, *, /): *
Result: 200
Output – 2:
Enter 2 number: 10 20
Enter an operator (+, -, *, /): ?
Error! Invalid Operator
OR

Output – 1:
Enter two numbers: 10 20
Enter an operator (+, -, *, /) : *
10*20=200
Output – 2:
Enter two numbers: 12 23
Enter an operator (+, -, *, /) : ?
Error! operator is not correct
9. Write a C++ program to print 1st 100 natural numbers.
OR
Write a program in C++ to print the number from 1 to 100.
Solution:

Output:
First 100 Natural Number:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
10. Write a C++ program to generate Multiplication Table.
OR
Write a C++ program to find the multiplication table of a number using for loop.
Solution:

Output:
Enter a number: 5
Multiplication Table of 5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
11. Write a C++ program to print multiplication table from 1 to 5.
Solution:

Output:
Multiplication Table from 1 to 5
1 x 1 = 1
1 x 2 = 2
1 x 3 = 3
1 x 4 = 4
1 x 5 = 5
1 x 6 = 6
1 x 7 = 7
1 x 8 = 8
1 x 9 = 9
1 x 10 = 10
————-
2 x 1 = 2
2 x 2 = 4
2 x 3 = 6
2 x 4 = 8
2 x 5 = 10
2 x 6 = 12
2 x 7 = 14
2 x 8 = 16
2 x 9 = 18
2 x 10 = 20
————-
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
————–
————-
12. Write a program to calculate sum of first n natural numbers.
Solution:

Output:
Enter a number: 6
Sum of first 6 natural number:21
13. Write a program to calculate the factorial of a number.
Solution:

Output:
Enter a number: 5
Factorial of 5 = 120
14. Write a program in C++ to print the following series:
1+1/2+1/3+1/4…….+1/n
Solution:

Output:
Enter the value of n: 4
Sum =2.08333
15. Write a C++ program to display Fibonacci Series.
Solution:

Output:
Enter the number of terms: 10
Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
16. Write a C++ program to print the following pattern:

Solution:

17. Write a C++ program to print the following pattern.

Solution:

18. Write a program in C++ to print the following pattern.

Solution:

19. Write a program in C++ to print the following pattern.

Solution:

20. Write a program in C++ to print the following pattern using.

Solution:

21. Write a C++ program to print the reverse of a given number.
OR
Write a program in C++ to reverse digits of an integer.
Solution:

Output:
Enter any number to reverse: 123
Reverse = 321
22. Write a C program to calculate the sum of a 3-digit number.
OR
Write a C program to find the sum of a given integer.
OR
Write a C program to find the sum of digits in a given number
Solution:

Output:
Enter a number: 456
Sum of digits = 15
23. Write a program to print elements of a one-dimensional (1D) array.
Solution:

OR

Output:
Array elements are: 3 4 2 6
24. Write a program to print elements of a one-dimensional (1D) array taking input from user.
Solution:

Output:
Enter 5 array elements: 2 5 8 1 4
Array elements are: 2 5 8 1 4
25. Write a program to print sum and average of array elements.
Solution:

Output:
Enter 5 elements in the array: 1 2 3 4 5
The array elements are: 1 2 3 4 5
Sum = 15
Average = 3
26. Write a program to calculate total and average marks of 5 subjects.
Solution:

Output:
Enter Mark1= 50
Enter Mark2= 70
Enter Mark3= 78
Enter Mark4= 89
Enter Mark5= 95
Total Marks: 382
Average Mark: 76.4
27. Write a program to find the biggest number in an array.
OR
Write a program in C++ to find the largest element of an array.
Solution:

Output:
Enter size of the array:5
Enter 5 elements: 2 8 5 7 3
Biggest no. of array: 8
28. Write a program in C++ to display the largest and smallest element in an integer array.
Or
Write a C++ program to find maximum and minimum element in array.
Solution:

Output:
Enter size of the array: 6
Enter 6 elements: 8 6 7 9 4 2
Largest element: 9
Smallest element: 2
29. Write a C++ program that counts the number of times each vowel has been entered in a line of text. Plot in the form of a horizontal histogram.
Solution:

Output -1:
Enter a string: ELIZA
A #
E #
I #
O
U
Output-2:
Enter a string: EDUCATION
A #
E #
I #
O #
U #
30. Write a program to print elements of a two-dimensional (2D) array.
Solution:

Output:
The array elements are:
1 2 5
3 4 1
31. Write a program to read and print elements of a two-dimensional (2D) array.
Solution:

Output:
Enter 12 elements in the array:
2 3 4 1 5 6 7 9 8 2 4 6
The array elements are:
2 3 4
1 5 6
7 9 8
2 4 6
32. Write a C++ program to find maximum and minimum element in a two-dimensional (2D) array.
Solution:

Output:
Enter number of rows and columns:2 3
Enter elements in the array:2 1 5 3 4 6
Maximum element:6
Minimum element:1
33. Write a program in C++ to display information of employees using structure.
Solution:

Output:
Enter the details of 3 employees:
Employee:1
Enter name: Raja Gogoi
Enter age: 25
Enter salary: 20000
Employee:2
Enter name: Nilom sharma
Enter age: 35
Enter salary: 30000
Employee:3
Enter name: Richa Das
Enter age: 25
Enter salary: 20000
Displaying Employee Information
Employee: 1
Name: Raja Gogoi
Age: 25
Salary: 20000
Employee: 2
Name: Nilom sharma
Age: 35
Salary: 30000
Employee: 3
Name: Richa Das
Age: 25
Salary: 20000
34. Write a program in C++ to calculate factorial using recursion.
Solution:

Output:
Enter a number: 5
Factorial of 5 = 120