C++ Coding Assignment (40 Questions)
Instructions: Write a C++ program for each question. Use proper input/output and formatting.
Part A: Basic Level (1–20)
1. Print Hello, World!
2. Add two numbers.
3. Find the sum, difference, product, and quotient of two numbers.
4. Find whether a number is even or odd.
5. Find whether a number is positive, negative, or zero.
6. Find the largest of two numbers.
7. Find the largest among three numbers.
8. Check whether a year is a leap year or not.
9. Swap two numbers without using a third variable.
10. Reverse a number.
11. Find the sum of digits of a number.
12. Check if a number is a palindrome.
13. Check if a number is an Armstrong number.
14. Find the factorial of a number.
15. Print the Fibonacci series up to n terms.
16. Count the number of digits in a number.
17. Find the sum of all even numbers between 1 and 100.
18. Find the sum of all odd numbers between 1 and 100.
19. Print all prime numbers between 1 and 100.
20. Check whether a number is prime or not.
Part B: Intermediate Level (21–40)
21. Find the maximum and minimum element in an array.
22. Sort an array in ascending order.
23. Search for an element in an array using linear search.
24. Search for an element in an array using binary search.
25. Find the sum and average of array elements.
26. Count positive, negative, and zero elements in an array.
27. Find the second largest element in an array.
28. Merge two arrays into one.
29. Copy elements from one array to another.
30. Reverse an array.
31. Count vowels and consonants in a string.
32. Reverse a string without using built-in functions.
33. Check whether a string is a palindrome.
34. Use a function to check whether a number is prime.
35. Use a function to calculate the factorial of a number.
36. Swap two numbers using pointers.
37. Find the sum of diagonal elements of a matrix.
38. Add two matrices.
39. Multiply two matrices.
40. Find the transpose of a matrix.