Answer to Question #297447 in C++ for Sabeeha

Question #297447

Write a program that prompts the user to input a decimal number and outputs the number rounded to the nearest integer. Your program should output only the nearest rounded value on a newline. 

Enter a decimal value: 2.2
2
1
Expert's answer
2022-02-13T14:13:10-0500


#include <iostream>


using namespace std;


int main()
{
	double decimalValue;
	cout<<"Enter a decimal value: ";
	cin>>decimalValue;
	cout<<(int)(decimalValue + 0.5)<<"\n\n";


	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog