/* * File: ave2f-boiler.c * Author: Jo Programmer * Class: CS 113, Fall 96 * Assignment: HW 1, problem 3 (problem 14 on page 6 of text) * Due Date: 1 April 1990 * Last modified: 2 April 1990 (1 day late) * ----------------------------------------------------- * * USAGE: ave2f (no commandline arguments) * ====== * * OVERVIEW: * ========= * This program prompts the user for two floating-point numbers * and displays the mean (average) of the two numbers to standard * output. * * Algorithm Notes: * ================ * Uses the obvious algorithm: (first number + second number) / 2. * * Known Bugs: none. * ================== * * Error Handling: * =============== * 1. User fails to enter floating-point numbers. * * Error message: text displayed indicating why the input is not * a floating-point number. * Error action: User given another chance to input. * * Other Comments: * =============== * This program could be enhanced so that it could take any quantity of * numbers. This could be done either by asking the user how many there * will be or by using a sentinel. * */ #include #include "genlib.h" #include "simpio.h" main() { double n1, n2, average; printf("This program averages two floating-point numbers.\n"); printf("1st number? "); n1 = GetReal(); printf("2nd number? "); n2 = GetReal(); average = (n1 + n2) / 2; printf("The average is %g\n", average); } /* ----------- END OF FILE: ave2f-boiler.c ---------- */