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