Download this source file


/* This program compues and prints the cost per hour for the intro to C class.
 * Note the use of variables which aid readability, and the fancy printf
 * which causes the output to appear rounded to two places.
 *
 * Written 2001 by Wayne Pollock, Tampa Florida USA
 */

#include <stdio.h>

int main ( void )
{
   int num_of_classes = 13;
   int hours_per_class = 3;
   int num_of_credits = 3;
   float cost_per_credit = 50.00f;
   float cost_of_book = 22.75f;

   printf( "The cost per hour is $%.2f.\n",
      ( ( num_of_credits * cost_per_credit + cost_of_book ) /
        ( num_of_classes * hours_per_class ) ) );

   return 0;
}




Send comments and mail to the WebMaster.