C repetition examples

C Programs - Loops

Practice C programs based on for loops, while loops, and do-while loops.

Topic library

33

practice programs

Topic overview

While programming, we often need to execute the same block of code repeatedly. Loops help us do that until a condition becomes false.

C supports three commonly used loop forms: for loop, while loop, and do-while loop.

Use these programs to practice counters, ranges, digit operations, factors, prime numbers, factorials, and repeated logic.

Practice list

Loop programs in C

33 programs
  1. 1C program to print all natural numbers from 1 to n
  2. 2C program to print all natural numbers in reverse
  3. 3C program to print alphabets from a to z
  4. 4C program to print all even numbers
  5. 5C Program to print all odd numbers
  6. 6C Program to find sum of all natural numbers
  7. 7C Program to find sum of all even numbers
  8. 8C Program to find sum of all odd numbers
  9. 9C Program to count number of digits in a number
  10. 10C program to find first and last digit of a number
  11. 11C program to find sum of first and last digit of a number
  12. 12C program to swap first and last digits of a number
  13. 13C program to find sum of digits of a number
  14. 14C program to find reverse of a number
  15. 15C program to check if a number is palindrome
  16. 16C program to find frequency of each digit in a given number
  17. 17C program to print number in words
  18. 18C program to find power of a number using loop
  19. 19C Program to find all factors of a number
  20. 20C program to calculate factorial of a number
  21. 21C program to find HCF of two numbers
  22. 22C program to find LCM of two numbers
  23. 23C program to check if a number is prime number
  24. 24C program to print all prime numbers from 1 to n
  25. 25C program to find sum of all prime numbers from 1 to n
  26. 26C program to find all prime factors of a number
  27. 27C Program to check if a number is armstrong
  28. 28C program to print all Armstrong numbers from 1 to n
  29. 29C Program to Check for Perfect Numbers
  30. 30C program to print all Perfect numbers from 1 to n
  31. 31C program to check if a number is Strong number
  32. 32C program to print all Strong numbers from 1 to n
  33. 33C program to print Fibonacci series