Skip to content
Home » C program to print even numbers using for loop

C program to print even numbers using for loop

Learn about C program to print even numbers using for loop in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C program to print even numbers using for loop \

The program takes minimum and maximum ranges as input and prints all the even numbers between them.

Source code:

#include<stdio.h>
int main()
{
  int minRange, maxRange;

  printf("Enter range value: ");
  scanf("%d %d",&minRange, &maxRange);
  
  printf("All even numbers from %d to %d are: \n", 
                            minRange, maxRange);
  for(int i=minRange; i<=maxRange; i++)
  {
    if(i%2 == 0)
    printf("%d ", i);
  }
  
  return 0;
}

Output:

Enter range value: 10 15
All even numbers from 10 to 15 are:
10 12 14

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Even Number Program in C
Simple Calculator program in C