To print the odd numbers in C


Levels of difficulty: / perform operation:

C program to print the odd numbers within a given number.

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	int i,n;
	clrscr();
	printf("\nENTER A NUMBER: ");
	scanf("%d",&n);
	printf("\nODD NUMBERS BETWEEN 1 AND %d ARE: \n",n);
	for(i=1;i<=n;i+=2)
	{
		printf("%d ",i);
	}
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview