C Program to print first n odd numbers using While loop
Write C Program to print first n odd numbers using While loop
//WAP to print first n odd numbers
#include <stdio.h>
int main()
{
int n;
printf("Enter the number :--> ");
scanf("%d",&n);
int i = 1;
int count = 0;
printf("The odd numbers are :--> ");
while(count < n)
{
if(i%2!=0)
{
printf("%d ",i);
count++;
}
i++;
}
return 0;
}
Output:
Enter the number :--> 8
The odd numbers are :--> 1 3 5 7 9 11 13 15