Control Statements Loops

70 programs in this topic — each includes source code, sample output and explanation.

  1. Print Numbers 1 to 10

    This program prints numbers from 1 to 10 using a for loop.

  2. Print Numbers 1 to 5

    This program prints numbers from 1 to 5 using a while loop.

  3. Print Numbers 1 to 3

    This program prints numbers from 1 to 3 using a do-while loop.

  4. Factorial of a Number

    This program calculates factorial of a number using for loop.

  5. Fibonacci Series

    This program prints Fibonacci series using while loop.

  6. Sum of Digits

    This program calculates the sum of digits of a number using while loop.

  7. Reverse a Number

    This program reverses a number using while loop.

  8. Check Prime Number

    This program checks if a number is prime using for loop.

  9. Multiplication Table

    This program prints multiplication table of 5 using for loop.

  10. Multiplication Tables 1 to 3

    This program prints multiplication tables from 1 to 3 using nested for loop.

  11. Check Armstrong Number

    This program checks if a number is Armstrong using while loop.

  12. Sum of First N Natural Numbers

    This program calculates sum of first N natural numbers using for loop.

  13. Factorial Using For Loop

    This program calculates factorial of a number using for loop.

  14. Check Palindrome Number

    This program checks if a number is palindrome using while loop.

  15. Prime Numbers in Range

    This program prints prime numbers between 1 and 20 using nested for loop.

  16. Sum of Even Numbers

    This program calculates the sum of even numbers from 1 to 20 using for loop.

  17. Sum of Odd Numbers

    This program calculates the sum of odd numbers from 1 to 19 using for loop.

  18. Factorial Using While Loop

    This program calculates factorial of a number using while loop.

  19. Prime Series up to N

    This program prints prime numbers up to 50 using for loop.

  20. Number Grid

    This program prints a 3x3 number grid using nested for loop.

  21. Sum of Squares

    This program calculates sum of squares of first 5 natural numbers.

  22. Sum of Cubes

    This program calculates sum of cubes of first 4 natural numbers.

  23. Count Digits in a Number

    This program counts the number of digits in a number using while loop.

  24. Sum of Even and Odd Numbers

    This program calculates sum of even and odd numbers separately using for loop.

  25. Sequential Number Triangle

    This program prints a triangle of sequential numbers using nested for loop.

  26. Sum of Factorial Series

    This program calculates the sum of factorials of first 5 numbers.

  27. Prime Factors of a Number

    This program prints prime factors of a number using while loop.

  28. Arithmetic Progression Series

    This program prints arithmetic progression series using for loop.

  29. Geometric Progression Series

    This program prints geometric progression series using for loop.

  30. Multiplication Table Grid

    This program prints multiplication tables from 1 to 3 in grid form.

  31. Sum of Arithmetic Progression

    This program calculates sum of arithmetic progression series.

  32. Sum of Geometric Progression

    This program calculates sum of geometric progression series.

  33. Pascal's Triangle (First 5 Rows)

    This program prints Pascal's Triangle using nested for loop.

  34. Sum of Prime Numbers

    This program calculates the sum of prime numbers up to 20 using for loop.

  35. Floyd's Triangle

    This program prints Floyd's Triangle using nested for loop.

  36. Sum of Prime Numbers up to N

    This program calculates the sum of prime numbers up to 30.

  37. Sum of Factorial Series

    This program calculates sum of factorials from 1! to 6!.

  38. Arithmetic Progression Sum

    This program calculates sum of arithmetic progression series.

  39. Geometric Progression Sum

    This program calculates sum of geometric progression series.

  40. Prime Number Triangle

    This program prints prime numbers in triangular form.

  41. Sum of Factorial Digits

    This program calculates sum of factorials of digits of a number.

  42. Arithmetic Progression Series with While Loop

    This program prints arithmetic progression series using while loop.

  43. Geometric Progression Series with While Loop

    This program prints geometric progression series using while loop.

  44. Arithmetic Progression Matrix

    This program prints a matrix of arithmetic progression values using nested for loop.

  45. Geometric Progression Pyramid

    This program prints a pyramid of geometric progression values using nested for loop.

  46. Prime Factorization Series

    This program prints prime factorization of a number using while loop.

  47. Factorial Summation Series

    This program calculates sum of factorials from 1! to 7!.

  48. Harmonic Series

    This program prints harmonic series up to 1/5.

  49. Multiplication Grid 1-5

    This program prints multiplication grid from 1 to 5 using nested for loop.

  50. Sum of Harmonic Series

    This program calculates sum of harmonic series up to 1/7.

  51. Number Pyramid

    This program prints a pyramid of numbers using nested for loop.

  52. Sum of Prime Factors

    This program calculates sum of prime factors of a number.

  53. Magic Square Pattern (3x3)

    This program prints a simple 3x3 magic square using nested for loop.

  54. Harmonic Series Sum with Precision

    This program calculates harmonic series sum with precision up to 1/10.

  55. Numeric Checkerboard Grid

    This program prints a numeric checkerboard grid using nested for loop.

  56. Factorial Sum of Series

    This program calculates sum of factorials from 1! to 8!.

  57. Prime Number Grid

    This program prints prime numbers in a 3x3 grid.

  58. Harmonic Progression Series

    This program prints harmonic progression series.

  59. Sum of Harmonic Progression

    This program calculates sum of harmonic progression series.

  60. Numeric Pyramid Pattern

    This program prints a pyramid of numbers using nested for loop.

  61. Factorial Sum with While Loop

    This program calculates sum of factorials from 1! to 5! using while loop.

  62. Prime Number Pyramid

    This program prints prime numbers in pyramid form.

  63. Harmonic Progression Sum with While Loop

    This program calculates sum of harmonic progression using while loop.

  64. Numeric Pyramid with Squares

    This program prints a pyramid of squares using nested for loop.

  65. Geometric Progression Pyramid with Powers of 3

    This program prints a pyramid of powers of 3 using nested for loop.

  66. Factorial Summation Grid

    This program prints a 3x3 grid of factorial values using nested for loop.

  67. Prime Checkerboard Grid

    This program prints a checkerboard of prime and non-prime indicators.

  68. Harmonic Progression Pyramid

    This program prints harmonic progression values in pyramid form.

  69. Sequential Number Diamond

    This program prints a diamond of sequential numbers using nested for loop.

  70. Advanced Numeric Sequence Grid

    This program prints a 4x4 grid of alternating squares and cubes.

Quick Links to Explore