Sunday, February 14, 2010

Write a C program to display all Even numbers upto the given range.

#include< stdio.h>
#include< conio.h>
int main( )
{
int x, r;
clrscr( );
printf("Enter the range:");
scanf("%d",&r);
for(x=1; x <=r; x++)
{
if(x%2==0)
printf("%5d", x);
}
getch( );
return 0;
}

Output:-
Enter the range:10
2 4 6 8 10

No comments:

Post a Comment