Friday, October 1, 2010

C program to print the even and odd numbers from 1 to 1000.

int main()
{
int i;
printf("Odd numbers between 1 to 1000\n");
for(i=1;i<=1000;i=i+2)
{
printf("%5d",i);
if(i%30==0)
printf("%\n");
}
printf("\nEven numbers between 1 to 1000\n");
for(i=2;i<=1000;i=i+2)
{
printf("%5d",i);
if(i%30==0)
printf("%\n");
}
getch();
}

No comments:

Post a Comment

Google+ Followers