30 Easy C++ Programming Questions on the Do-while loop


Q 1. Write a program to Print numbers from 1 to 5

Expected Output:

1 2 3 4 5

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 X 1 = 5

5 X 2 = 10

...

5 X 10 = 50

Q 5. Reverse countdown from 10 to 1

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. Find the first number divisible by 7 greater than 10

Expected Output:

First number = 14

Q 10. Print ASCII values of characters from 'A' to 'E'

Expected Output:

A = 65

B = 66

C = 67

D = 68

E = 69

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

Expected Output:

Sum of digits = 10

Q 12. Check if a number is a palindrome (e.g., 121)

Expected Output:

121 is a palindrome

Q 13. Count the number of digits in a number (e.g., 7890)

Expected Output:

Number of digits = 4

Q 14. Find the greatest common divisor (GCD) of two numbers (e.g., 24 and 36)

Expected Output:

GCD = 12

Q 15. Convert a number to binary (e.g., 5)

Expected Output:

Binary = 101

Q 16. Find the power of a number (e.g., 2^3)

Expected Output:

Result = 8

Q 17. Sum of digits of a number until a single digit is obtained (e.g., 9875)

Expected Output:

Single digit sum = 2

Q 18. Print Fibonacci series up to 10 terms

Expected Output:

0 1 1 2 3 5 8 13 21 34

Q 19. Find the sum of the first 5 prime numbers

Expected Output:

Sum = 28

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

Expected Output:

*

**

***

****

*****

Q 21. Reverse the digits of a number (e.g., 12345)

Expected Output:

Reversed number = 54321

Q 22. Find the largest digit in a number (e.g., 68952)

Expected Output:

Largest digit = 9

Q 23. Find the sum of squares of digits of a number (e.g., 123)

Expected Output:

Sum of squares = 14

Q 24. Check if a number is Armstrong (e.g., 153)

Expected Output:

153 is an Armstrong number

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

Expected Output:

Sum of series = 2.28333

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

Expected Output:

29 is a prime number

Q 27. Calculate compound interest for 3 years (Principal = 1000, Rate = 5%)

Expected Output:

Compound interest = 157.625

Q 28. Find the product of first 5 positive integers

Expected Output:

Product = 120

Q 29. Calculate sum of cube of first 4 numbers

Expected Output:

Sum of cubes = 100

Q 30. Print numbers from 1 to 10 using a single statement

Expected Output:

1 2 3 4 5 6 7 8 9 10

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!

Programming Languages