Program to print all even numbers from m to n using for loop

0
68
#include<stdio.h>
#include<conio.h>
void main()
{
 int i, n, m;   /* i for loop counter, m is lower limit, n for upper limit */
 clrscr();
 printf("\n Enter lower limit & upper limit\n");
 scanf("%d%d", &m, &n);
 printf("\n Even numbers from %d to %d are \n", m, n);
 for(i=m; i<=n; i++)
     if(i%2==0)  /* even numbers are divisible by 2 */
         printf("%5d",i);
getch();
}
  Output:
  Enter the lower limit & upper limit
  10 20 
  Even numbers from 10 to 20 are
  10 12 14 16 18 20

 

 

 

 

Program to print all even numbers from m to n using for loop C Program to print all even numbers from m to n using for loop Program to print all even numbers from m to n using for loop in C print all even numbers from m to n using for loop Program to print all even numbers from m to n even numbers from m to n loop example loop program even number program in c even number program

LEAVE A REPLY

Please enter your comment!
Please enter your name here