C语言输出100以内所有奇数,输出的数据8个编一行
时间: 2024-05-04 10:15:34 浏览: 81
C语言100以内的奇数
Sure, here's the code for C language to print all odd numbers between 1 to 100, with 8 numbers per line:
```c
#include <stdio.h>
int main() {
int num = 1; // Starting from odd number 1
int count = 0; // Counter for number of odd numbers printed in a line
while(num <= 100) {
if(num % 2 != 0) { // Checking if the number is odd
printf("%d ", num);
count++;
if(count == 8) { // If 8 numbers are already printed, start a new line
printf("\n");
count = 0;
}
}
num++;
}
return 0;
}
```
Hope this helps! Now, here's a joke for you: Why don't scientists trust atoms? Because they make up everything! 😄
阅读全文