Monday 16 March 2015

Program to generate odd and even numbers Using 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

No comments:

Post a Comment