Write a program to print odd number and get range from user in C-Language.

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;
}


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.