+ 3
How to round up the value of output in C++ ??? If Anyone knows the answer ,Please let me know.
3 Respuestas
+ 2
At the top, put:
#include <cmath>
When you want to round and have "using namespace std;" line:
round(numbergoeshere);
When you want to round without "using namespace std;" line:
std::round(numbergoeshere);
+ 3
There is a function round() in cmath. You may use that. Or, just cast to int using the following syntax:
double myvar;
cout<<int(myvar);
or:
cout<<static_cast<int>(myvar);
+ 2
ceil() for round up, floor() for round down and round () for round off