To print the even numbers in C


Levels of difficulty: / perform operation:

C program to print the even numbers within a given number.

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	int i,n;
	clrscr();
	printf("\nENTER A NUMBER: ");
	scanf("%d",&n);
	printf("\nEVEN NUMBERS BETWEEN 1 AND %d ARE: \n",n);
	for(i=2;i<=n;i+=2)
        {
		printf("%d ",i);
	}
	getch();
}


Output