In this easy coded program, you will learn how to print odd numbers
from 1 to 'n' using while loop. Here, 'n',i.e. the end point will be
given by the user and hence we will need to take input of the same.
---------------------------------------------------------------------------
Hope you found this 'C Program to Print Odd Numbers from 1 to 'n'- while Loop' easy, simple and helpful!
Try to solve more queries by yourself by referring more examples from BEGINC. Here you will get the most easiest code to each and every query. Keep practicing. More programs are coming.
---------------------------------------------------------------------------
Program to Print Odd Numbers from 1 to 'n'
/*Odd Numbers from 1 to n- while Loop*/
|
|
#include<stdio.h>
|
|
void main()
|
{
|
int
i=1,
num;
|
|
printf("Enter Number: ");
|
scanf("%d", &num);
|
|
while(i<=num)
|
{
|
printf("%d\t", i);
|
i+=2;
|
}
|
}
|
Output
Enter Number: 18
1 3 5 7 9 11 13 15 17
---------------------------------------------------------------------------Hope you found this 'C Program to Print Odd Numbers from 1 to 'n'- while Loop' easy, simple and helpful!
Try to solve more queries by yourself by referring more examples from BEGINC. Here you will get the most easiest code to each and every query. Keep practicing. More programs are coming.
Comments
Post a Comment
Please do not comment any spam links in the comment box.