用c语言使用循环语句实现自然数1~99的遍写

如题所述

可以使用for循环或while循环实现自然数1~99的遍写。以下是两种实现方式:

for循环实现:
c

#include <stdio.h>

int main() {
for (int i = 1; i <= 99; i++) {
printf("%d\n", i);
}
return 0;
}
while循环实现:
c

#include <stdio.h>

int main() {
int i = 1;
while (i <= 99) {
printf("%d\n", i);
i++;
}
return 0;
}
两种方式的输出结果都是自然数1~99。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-11-13
参考代码如下:
#include<stdio.h>

int main()
{
int i;
for(i=1;i<=99;++i)
printf("%d ",i);
return 0;
}本回答被网友采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网