Ad Code

Ticker

6/recent/ticker-posts

Program To Print First n Even And Odd Numbers


C PROGRAM

/*program to print first n even and odd numbers*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=1,j=2,c;
clrscr();
printf("\nEnter the value for n\n");
scanf("%d",&n);
printf("\nfirst %d odd numbers are\n",n);
c=1;
while(c<=n)
{
printf("%d ",i);
i=i+2;
c++;
}
printf("\nFirst %d even numbers are\n",n);
c=1;
while(c<=n)
{
printf("%d ",j);
j=j+2;
c++;
}
getch();

}

OUTPUT:

Reactions

Post a Comment

0 Comments

Ad Code