30 Easy C++ Programming Questions on the topic For loop


Q 1. Print numbers from 1 to 10

Expected Output:

1 2 3 4 5 6 7 8 9 10

Q 2. Print even numbers from 2 to 10

Expected Output:

2 4 6 8 10

Q 3. Sum of numbers from 1 to 10

Expected Output:

Sum = 55

Q 4. Print multiplication table of 5

Expected Output:

5 * 1 = 5

5 * 2 = 10

...

5 * 10 = 50

Q 5. Print numbers from 10 to 1 in reverse

Expected Output:

10 9 8 7 6 5 4 3 2 1

Q 6. Find factorial of a number (e.g., 5)

Expected Output:

Factorial = 120

Q 7. Print first 5 odd numbers

Expected Output:

1 3 5 7 9

Q 8. Sum of first 5 even numbers

Expected Output:

Sum = 30

Q 9. Print all numbers divisible by 3 between 1 and 30

Expected Output:

3 6 9 12 15 18 21 24 27 30

Q 10. Print the squares of numbers from 1 to 5

Expected Output:

1 4 9 16 25

Q 11. Sum of squares of first 5 numbers

Expected Output:

Sum of squares = 55

Q 12. Find the product of first 5 numbers

Expected Output:

Product = 120

Q 13. Find the sum of digits of a number (e.g., 1234)

Expected Output:

Sum of digits = 10

Q 14. Print numbers from 1 to 10 skipping multiples of 3

Expected Output:

1 2 4 5 7 8 10

Q 15. Check if a number is prime (e.g., 29)

Expected Output:

29 is a prime number

Q 16. Print first 10 terms of the Fibonacci series

Expected Output:

0 1 1 2 3 5 8 13 21 34

Q 17. Print a right-angled triangle of stars (5 levels)

Expected Output:

*

* *

* * *

* * * *

* * * * *

Q 18. Find the sum of the series 1 + 1/2 + 1/3 + ... + 1/n (n=5)

Expected Output:

Sum of series = 2.28333

Q 19. Reverse the digits of a number (e.g., 16805)

Expected Output:

Reversed number = 50861

Q 20. Find the GCD of two numbers (e.g., 24 and 36)

Expected Output:

GCD = 12

Q 21. Print the first 10 multiples of a number (e.g., 7)

Expected Output:

7 14 21 28 35 42 49 56 63 70

Q 22. Calculate the power of a number (e.g., 3^4)

Expected Output:

3^4 = 81

Q 23. Count the number of digits in a number (e.g., 54321)

Expected Output:

Number of digits = 5

Q 24. Print numbers from 1 to 50 but skip multiples of 5

Expected Output:

1 2 3 4 6 7 8 9 11 12 13 14 16 ... 49

Q 25. Find the sum of the first 10 odd numbers

Expected Output:

Sum = 100

Q 26. Print ASCII values of characters 'A' to 'Z'

Expected Output:

A = 65

B = 66

...

Z = 90

Q 27. Reverse an array of integers (e.g., {1, 2, 3, 4, 5})

Expected Output:

5 4 3 2 1

Q 28. Find the average of 5 numbers input by the user

Expected Output:

(Example input: 1 2 3 4 5)

Average = 3

Q 29. Find the sum of digits of all elements in an array (e.g., {12, 34, 56})

Expected Output:

Sum of digits = 21

Q 30. Find the sum of cubes of the first 5 natural numbers

Expected Output:

Sum of cubes = 225

Social Share

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!