write a program that prompts the user to input five decimal numbers
Posted
by user312309
on Stack Overflow
See other posts from Stack Overflow
or by user312309
Published on 2010-04-08T21:33:36Z
Indexed on
2010/04/08
22:43 UTC
Read the original article
Hit count: 173
This is the question.
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,m and print the result.
This is what I've gotten so far:
// p111n9.cpp : Defines the entry point for the console application.
//
#include <iostream>
using namespace std;
double a, b , c , d , e, f;
int main(int argc, char* argv[])
{
cout << "enter 5 decimals: " << endl;
cin >> a >> b >> c >> d >> e;
f = a + b + c + d + e;
return 0;
}
Now I just need to convert the sum(f
) to the nearest integer, m
and print the result. How do I do this?
© Stack Overflow or respective owner