C Program Print One To N Odd Natural Numbers

By | March 7, 2020

C Program Print One To N Odd Natural Numbers

Output:

Enter a number to show odd natural numbers from 1 to N:20
Odd Natural Numbers from 1 to 20 are:
1
3
5
7
9
11
13
15
17
19

C Code / C Program Print One To N Odd Natural Numbers

#include<stdio.h>
int main()
{
        int n,i;
    
	printf("Enter a number to show odd natural numbers from 1 to N:");
	scanf("%d", &n);
	printf("Odd Natural Numbers from 1 to %d are:\n",n);
	
	for(i=1;i<=n;i++)
	  if(i%2==1)
	  printf("%d\n", i);
    
        return 0;
}

Loading

Leave a Reply

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