C语言输出100以内的奇数

img


大家帮我看看错在哪 不知道错在哪里的C语言输出100以内的奇数

if (a % 2 == 1)要写在循环里面

int a = 0;
while (a < 100) {
    if (a % 2 == 1) printf("%d ", a);
    a++;
}

while后没加括号,导致循环里只有个a++,后面的代码都在循环外面

#include <stdio.h>

int main() {
    int a = 0;
    
    while (a < 100) {
        if (a % 2 != 0) {
            printf("%d ", a);
        }
        a++;
    }
    
    return 0;
}


谢谢大家!!!