C++ Loops (For, While, Do-While, break, continue)

Back To C++ Index


1. program to demonstrate for statement to display numbers from 0 to 9 - Code
2. program to demonstrate for statement to display numbers from 0 to 10 - Code
3. program to display numbers from 9 to 0 (in reverse order) using for statement - Code
4. program to display numbers from 10 to 0 (in reverse order) using for statement - Code
5. program to display numbers 0 to 10 with a gap of 2 between the numbers using for statement - Code
6. program to display numbers 0 to 50 with a gap of 5 between the numbers using for statement - Code
7. program to display numbers 50 to 1 (in reverse order) with a gap of 5 between the numbers using for statement - Code
8. program to find sum of numbers from 1 to 10 using for statement - Code
9. program to find sum of even numbers from 1 to 10 using for statement - Code
10. program to find sum of odd numbers from 1 to 10 using for statement - Code
11. program to find sum of even and odd numbers from 1 to 10 statement - Code
12. program to input two numbers a and b and display numbers between them using for statement - Code
13. program to input two numbers a and b and find sum of numbers between them using for statement - Code
14. program to find factorial of a number using for statement - Code
15. program to find whether number entered is prime or not using for statement - Code
16. program to print first 1 to 10 terms of fibonicci series using for statement - Code
17. program to print pattern of stars using for statement (example of nested for loop) - Code
18. program to print table of a number entered by the user using for statement - Code
19. program to print numbers from 0 to 9 using while statement - Code
20. program to print numbers from 1 to 10 using while statement - Code
21. program to print numbers from 1 to 10 with a gap of 2 numbers using while statement - Code
22. program to find factorial of a number using while statement - Code
23. program to print table of a number entered by user using while statement - Code
24. program to find sum of numbers from 1 to 10 using while statement - Code
25. program to input two numbers and find sum of numbers between them using while statement - Code
26. program to find sum of even and odd numbers between a and b using while statement - Code
27. program to check whether a number is prime or not using while statement - Code
28. program to print first 1 to 10 terms of fibonicci series using while statement - Code
29. program to find lcm and hcf of 2 numbers using while loop - Code
30. program to demonstrate do while statement example to print numbers 1 to 10 - Code
31. program to demonstrate do while example 2, prints 11 on the output screen - Code
32. program to demonstrate break statement in for loop - Code
33. program to demonstrate break statement in while loop - Code
34. program to demonstrate continue statement in for loop - Code
35. program to input a number and find sum of digits of the number - Code
36. program to input a number and count number of digits in the number - Code
37. program to input a number and find whether it is palindrome or not (1221 is a palindrome and 1234 is not a palindrome) - Code
38. program to input a number and print reverse of the number using while loop - Code
39. program to input a number n and print pattern of numbers from 1 to n (example of nested loop) - Code
40. program to find sum of series (11/1! + 22/2! + 33/3! + .... n - Code
41. program to find factorial of number using for loop with decrement operator - Code