C program to print all odd numbers from 1 to n using for but without if
#include<stdio.h>
int main()
{
int i, n;
printf("Enter to print all odd numbers till: ");
scanf("%d",&n);
for(i=1;i<=n;i+=2)
{
printf("%d\n",i);
}
return 0;
}
Output
Enter to print all odd numbers till: 11
1
3
5
7
9
11