this program will print all the odd numbers under the number entered by user when this program is executed.in this program we have b=1 as a first odd number.then after printing first number it will increase the value of 'b' and new value will be 3 which is also a odd number and like this, program will run till condition becomes false in for loop.
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter Number: ");
scanf("%d",&b);
printf("\n");
for(a=1;a<=b;a+=2)
{
printf("%d,",a);
}
getch();
}
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter Number: ");
scanf("%d",&b);
printf("\n");
for(a=1;a<=b;a+=2)
{
printf("%d,",a);
}
getch();
}