+ 3

How to round up the value of output in C++ ??? If Anyone knows the answer ,Please let me know.

18th Oct 2017, 1:30 PM
Adesh Choudhar
Adesh Choudhar - avatar
3 Answers
+ 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);
18th Oct 2017, 2:19 PM
LunarCoffee
LunarCoffee - avatar
+ 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);
18th Oct 2017, 2:17 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
ceil() for round up, floor() for round down and round () for round off
7th Apr 2018, 4:06 PM
Kuldeep Singh
Kuldeep Singh - avatar