Math, asked by gurleenkour469, 3 months ago

c program to print odd number from 1 to N using while loop​

Answers

Answered by Mrjaiswal09
3

Step-by-step explanation:

#include <stdio.h>

int main()

{

int n;

number=1;

printf("Enter the value of N: ");

scanf("%d",&n);

printf("Odd Numbers from 1 to %d:\n",n);

while(number<=n)

{

if(number%2 != 0)

printf("%d ",number);

number++;

}

return 0;

}

OR

#include<stdio.h>

int main()

{

int i = 1, number;

printf("\n Please Enter the Maximum Limit Value : ");

scanf("%d", &number);

printf("\n Odd Numbers between 1 and %d are : \n", number);

while(i <= number)

{

printf(" %d\t", i);

i = i + 2;

}

return 0;

}

Similar questions