Write a program to print odd number and get range from user in C-Language.
Hasnain Altaf
May 07, 2022
Write a program to print odd number and get range from user in C-Language.
#include <conio.h>
#include <stdio.h>
int main() {
int a,i,count=0;
printf("Enter number for printing odd number till\n");
scanf("%d",&a);
printf("You enter %d \n",a);
for(i=1;i<=a;i=i+2){
printf("%d \n",i);
if (a%2==1){
count=count+1;
}
else if(a%2==0)
{
a=a-1;
if(a%2==1)
{
count=count+1;
}
}
}
printf("\nNumbers of odd numbers is %d. ",count );
return 0;
}