Tuesday, 5 September 2017

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

PROGRAM :   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)     //To Check given odd or not
                    printf("%d\n",i);
      }
return 0;

 }

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

OUTPUT :



No comments:

Post a Comment