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 while loop.
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int a,b=1;
clrscr();
printf("Enter Nuumber: ");
scanf("%d",&a);
while(b<=a)
{
printf("%d,",b);
b+=2;
}
getch();
}
main()
{
int a,b=1;
clrscr();
printf("Enter Nuumber: ");
scanf("%d",&a);
while(b<=a)
{
printf("%d,",b);
b+=2;
}
getch();
}