Homework 15: First functions
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Wednesday, February 22
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw15and submit using the204subcommand. - This is an electronic homework and you do not need to print out anything to turn in during class.
Assignment
- Required reading: Sections 1 (writing functions) and 2 (function design) from the Unit 5 notes,
-
Write a program called
average.cthat reads in three numbers and prints out their average.Write and use a function with the following prototype to compute the average:
double average(double x, double y, double z);Example runs:
roche@ubuntu$./averageEnter three numbers:1 2 3The average is 2roche@ubuntu$./averageEnter three numbers:2.1 2.1 2.1The average is 2.1roche@ubuntu$./averageEnter three numbers:8 6 12The average is 8.66667