/********************************************************* * From C PROGRAMMING: A MODERN APPROACH, 1st Edition * * By K. N. King * * Section 9.1, pages 157-158. * *********************************************************/ #include /* The following function does not return any value. For this reason it has type "void". It takes one argument of type integer. */ void counting(int a) { printf("This is iteration number %d\n", a); } int main( void ) { int i; /* The following examples repeatedly call a function counting(a) that has no return value. For this reason, function call is a program statement followed by ";". In this case, it is not an arithmetical expression. */ /* Example 1 */ for(i=0; i < 11; i++) { /* call function only for even numbered iterations */ if ( i%2 == 0) counting( i ); } printf("\n"); /* Example 2 */ for(i=10; i > 0; i--) { /* since this loop counts down from 10 to 0, argument is (10 - i)*/ counting( 10 - i ); } return( 0 ); }