C Programs - Loops


While programming we usually come across a requirement where we want to execute a block of code repetitively.
Loops help us to achieve such functionality.

A loop executes a block of code until the condition given to it becomes false.

Basically there are three types of loop in C language

  1. for loop
  2. while loop
  3. do-while loop

List of programs

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