{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AverageOfSeveral - << endl cout<<"The average...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> using namespace std ; double avg (double v1, double v2) { return (v1 + v2) / 2 ; } double avg (double v1, double v2, double v3) { return (v1 + v2 + v3) / 3 ; } double avg (double v1, double v2, double v3, double v4) { return (v1 + v2 + v3 + v4) / 4 ; } double avg (double v1, double v2, double v3, double v4, double v5) { return (v1 + v2 + v3 + v4 + v5) / 5 ; } int main() { cout << "Using function overloading to simplify an average function."
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: << endl ; cout << "The average of 1.3 and 2.4 is " << avg(1.3, 2.4) << endl ; cout << "The average of 1.3, 2.4 and 5.6 is " << avg(1.3, 2.4, 5.6) << endl ; cout << "The average of 1.3, 2.4, 5.6 and 7.8 is " << avg(1.3, 2.4, 5.6, 7.8) << endl ; cout << "The average of 1.3, 2.4, 5.6, 7.8 and 9.5 is " << avg(1.3, 2.4, 5.6, 7.8, 9.5) << endl ; }...
View Full Document

{[ snackBarMessage ]}