C Program to generate odd and even numbers

/* Program to generate odd and even numbers – GENODDEV.C */
# 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

This entry was posted in C,C++ Programing and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>