// Write a program that prompts the user to input five decimal numbers. The program // should then add the five decimal numbers, convert the sum to the nearest integer, and // print the result. // This program illustrates the use of a function to calculate the nearest integer. #include using namespace std; int round(double value); // function prototype int main() { double N1, N2, N3, N4, N5; double sum; int nearest_int; cout << " Please enter 5 numbers " << endl; cin >> N1 >> N2 >> N3 >> N4 >> N5; sum = N1 + N2 + N3 + N4 + N5; // calc the nearest integer nearest_int = round(sum); // output the results cout << endl << "The sum of your numbers is " << sum << endl; cout << "and the nearest integer to the sum is " << nearest_int << endl; } // declaration of round function int round(double value) { return int(value + 0.5); }