C examples for Data Type:int
Count the number of even numbers between 0 and 100.
#include <stdio.h> int main( void ) { static int count = 0; for (int x = 0; x < 101; x++) {//from w w w .j a v a 2 s .c o m if (x % 2 == 0) /*if x is even...*/ count++; /*add 1 to count.*/ } printf("There are %d even numbers.\n", count); return 0; }