C Program to generate odd and even numbers

/* to generate odd and even numbers – GENODDEV. */
# include <stdio.h>
# include <conio.h>
void main()
{
int n, i ;
clrscr() ;
printf(“Enter the limit : “) ;
scanf(“%d”, &n) ;
printf(“\nThe odd numbers are :\n\n”) ;
for(i = 1 ; i <= n ; i = i + 2)
printf(“%d\t”, i) ;
printf(“\n\nThe even numbers are :\n\n”) ;
for(i = 2 ; i <= n ; i = i + 2)
printf(“%d\t”, i) ;
getch() ;
}
RUN 1 :
~~~~~~~
Enter the limit : 10
The odd numbers are :
1 3 5 7 9
The even numbers are :
2 4 6 8 10

Be the first to comment

Leave a Reply

Your email address will not be published.


*