How can i round off 200/3 in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i round off 200/3 in c++?

I need this to solve Halloween candy challenge in code coach in sololearn.

20th Feb 2020, 10:59 AM
RIJU JOSDAS
RIJU JOSDAS - avatar
8 Answers
+ 2
Use <cmath> header. Use round, ceil , floor whichever fits your need , challenge gives you enough details to determine. https://www.programiz.com/cpp-programming/library-function/cmath
20th Feb 2020, 11:01 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 2
Use floor to round down Use ceil to round up Use search as this question has been answered before.
20th Feb 2020, 11:02 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
RIJU JOSDAS Did you bother to read and understand the answers you received?
20th Feb 2020, 3:01 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
If you want to solve this problem there is no need to use any rounding off operator as it can be done without it too. #include <iostream> using namespace std; int main() { int houses; int a; cin>> houses; a=200/houses; if (200%houses==0) cout<< a; else cout<< a+1; return 0; } Like this.
22nd Feb 2020, 7:04 AM
Aryaman Mishra 🇮🇳
Aryaman Mishra 🇮🇳 - avatar
0
Bro round isn't working
20th Feb 2020, 2:46 PM
RIJU JOSDAS
RIJU JOSDAS - avatar
0
It always rounds down and never rounds up
20th Feb 2020, 2:46 PM
RIJU JOSDAS
RIJU JOSDAS - avatar
0
Bro i tried them already
20th Feb 2020, 3:03 PM
RIJU JOSDAS
RIJU JOSDAS - avatar