ITPub博客

首页 > 应用开发 > IT综合 > C语言基础:输出100以内的奇数和偶数

C语言基础:输出100以内的奇数和偶数

IT综合 作者:cccc1777 时间:2016-04-29 15:00:45 0 删除 编辑
摘自:http://www.q3060.com/list6/list143/4931.html

#include <stdio.h>

int main()
{
int counter;

printf("\nEven values\n");
for (counter = 1; counter <= 100; counter++)
{
if (!(counter % 2)) // Even
printf("%d ", counter);
}

printf("\nOdd values\n");
counter = 0;
while (counter <= 100)
{
counter++;

if (counter % 2) // Odd
printf("%d ", counter);
}

return 1;
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29532788/viewspace-2090645/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-03-11

  • 博文量
    37
  • 访问量
    50288