Program to generate odd and even numbers
Program:
#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();
}
Output:
Enter the limit : 10
The odd numbers are :
1 3 5 7 9
The even numbers are :
2 4 6 8 10
-
UpdatedDec 30, 2019
-
Views13,352
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order