Monday, 4 September 2017

C-Program to print all the odd number till ‘N’



#include<stdio.h>
  
int main()
 {
 int i,n;
printf("Enter a Number to print all odd number between 0 and N \n");
 scanf("%d",&n);
 for(i=0;i<=n;i++)
 {
 if(i%2==1)
 printf("%d\n",i);
 else
 continue;
 }
 printf("\n");
return 0;
 }

Input :  15
Output : 1 3 5 7 9 11 13 15

No comments:

Post a Comment