+ 1

How to round off decimal to nearest whole number in c++?

I'm new to C++ In a problem, the expected output should be 67 but it gives 66 when input value is 3. (200/3=66) Would someone help me, please. Thank you.

19th Jun 2021, 6:24 AM
Limbo
Limbo - avatar
5 Answers
+ 4
#include <iostream> #include <cmath> using namespace std; int main() { cout << ceil(200.0/3); return 0; }
19th Jun 2021, 6:44 AM
TOLUENE
TOLUENE - avatar
+ 3
First, tell me, do you need to round the number to its nearest value or round a number up to its nearest whole value? For example: input: 45.3 what should be the expected output? 45 or 46? If you want to round it to the nearest value,you can use the round function: https://code.sololearn.com/ca20A16A0a0a Otherwise, use ceil function .If you want to round a number up to its nearest whole value.
19th Jun 2021, 6:42 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
Thank you very much all of you
19th Jun 2021, 3:11 PM
Limbo
Limbo - avatar
0
File handling statement c++ An audit firm have employees and customers. Customers can create request for audit, view current audit status and can view previous audit reports. Create a nested structure program for such firm that stores audit, customers and employees’ information in file. Each audit is conducted by an employee and is initiated by a customer.
21st Jun 2021, 5:30 AM
Ibtesaam Aslam
Ibtesaam Aslam - avatar