If you input even numbers, only the odd numbers will be printed until it reaches 0. (0 will not be printed). For example, if you input 10, the output would be 9, 7, 5, 3, 1.
This is what I came up with. I'm wondering what should I decrement x by to get the desired output.
int x;
scanf("%d", &x);
while (x >= 0) {
printf("%d", x);
x = x - 2;
}
int x, n;
printf("Give N: ");
scanf("%d", &n);
printf("odd numbers from 1 to %d are: \n", n);
x=n;
while(x<=n && x>0)
{
if(x%2!=0)
{
printf("%d\n", x);
}
x--;
}
return 0;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments