Home Segments Index Top Previous Next

45: Mainline

You can initialize variables, as in the following program:

#include  
main ( ) { 
  int size_one = 600; 
  int size_two = 100; 
  int size_three = 200; 
  printf ("The average number of shares traded is "); 
  printf ("%i", (size_one + size_two + size_three) / 3); 
  printf ("\n"); 
} 
--- Result --- 
The average number of shares traded is 300 

Note that the print specification for integers is %i, rather than %f, which is appropriate only for floating-point numbers.