goinaction / code

Source Code for Go In Action examples
4.13k stars 2.37k forks source link

Program to display odd numbers without using if statement. #56

Closed itzmahi07 closed 3 years ago

itzmahi07 commented 3 years ago

include

int main() { int i, n;

printf("Print odd numbers till: ");
scanf("%d", &n);

printf("All odd numbers from 1 to %d are: \n", n);

for(i=1; i<=n; i+=2)
{
    printf("%d\n", i);
}

return 0;

}