C Program to print ODD numbers from 1 to N

#include<stdio.h> #include<conio.h> main( ) { int i,n; clrscr( ); printf("Print odd numbers till:"); scanf("%d",&n); printf("All odd numbers from 1 to %d are:\n",n); for (i=1; i<=n; i++) { if(i%2!=0) { printf("%d\n",i); } } getch( ); }


Output:


Run-1



Run-2



1 comment:

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...