Pages

Saturday, July 2, 2016

C Program to print Odd number series 1 3 5 7 ... N for the given value of N.



C Program to print Odd number series 1 3 5 7 ... N for the given value of N.

For example, if N=10, output should be
1 3 5 7 9


#include<stdio.h>
int main()
{
 int i, N;
 printf("Enter N:");
 scanf("%d", &N);

 for(i=1; i<=N; i=i+2)
 {
   printf("%d ",i);
 }
 return 0;
}

Output of program

Enter N:10
1 3 5 7 9

No comments:

Post a Comment