ex12_07.c

来自「c21Examples.rar」· C语言 代码 · 共 21 行

C
21
字号
/*Count the number of even numbers between 0 and 100. */

#include <stdio.h>

int main( void )
{
   int x = 1;
   static int tally = 0;

   for (x = 0; x < 101; x++)
   {
      if (x % 2 == 0)  /*if x is even...*/
      tally++;  /*add 1 to tally.*/

   }

   printf("There are %d even numbers.\n", tally);
   return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?