home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day12
/
Ex12_07.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-05-04
|
343b
|
21 lines
/*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;
}