Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i;
printf("Enter any Number : ");
scanf("%d", &n);
printf("\n\nEven Numbers from 1 to %d is : \n\n ", n);
i=1;
while (i<=n)
{
if(i%2==0)
printf("\t%d", i);
i++;
}
printf("\n\nOdd Numbers from 1 to %d is : \n\n ", n);
i=1;
while (i<=n)
{
if(i%2!=0)
printf("\t%d", i);
i++;
}
getch();
}
Output:
Enter any Number : 10
Even Numbers from 1 to 10 is :
2 4 6 8 10
Odd Numbers from 1 to 10 is :
1 3 5 7 9
Next Topic :
Previous Topic :
No comments:
Post a Comment