Skip to content
Home » Even Odd Program in C Using for loop

Even Odd Program in C Using for loop

Learn about Even Odd Program in C 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.

Even Odd Program in C Using for loop

The below program takes minimum and maximum ranges to display the results between those numbers.

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

  printf("Enter range value: ");
  scanf("%d %d",&minRange, &maxRange);
  
  for(int i=minRange; i<=maxRange; i++)
  {
    if(i%2 == 0)
    printf("%d: Even\n", i);
    else printf("%d: Odd\n", i);
  }
  
  return 0;
}

Output:

Enter range value: 1 10
1: Odd
2: Even
3: Odd
4: Even
5: Odd
6: Even
7: Odd
8: Even
9: Odd
10: Even

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 Odd Program in C Using the Conditional Operator
Even Odd Program in C Using the Switch case