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
#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;
}
Comments
Leave a comment