0
Can anyone tell me what's wrong in this code ?
Help me plz I am solving the "Paint Cost" code coach in C++ language but case 5 failed Plz tell me what's wrong with this 👇 👇 #include <iostream> #include <cmath> using namespace std; int main() { float a,b,c; cin>>a; b=a*5+40; c=b+0.1*b; cout<<round(c); return 0; } Plz help me out guys 🙏🙏
11 Réponses
+ 5
Krishnendu Dey
Use ceil instead of round because you need nearest whole positive number.
cout<<int(ceil(c));
+ 8
int d = round(c);
cout<<d;
+ 5
Krishnendu Dey
round (4.4) = 4
ceil(4.4) = 5
round (4.6) = 5
ceil(4.6) = 5
remember in C++ gives 4 or 5 as int instead of 4.0 or 5.0
in Java returns 4.0 or 5.0 as double value
+ 4
🅰🅹 🅐🅝🅐🅝🅣 Thank you dude for helping 😀
I'm greatful to u 🙏🙏
+ 4
🅰🅹 🅐🅝🅐🅝🅣 Thanks for telling
+ 3
Simba Thanks for the answer.
But still confused how 'int' makes the difference ?
+ 2
🅰🅹 🅐🅝🅐🅝🅣 Btw can u please tell what's the difference between 'ceil' and 'round ' ?
+ 2
Benjamin Ansah
What is the problem?
And please make new question. Don't post in others question.
- 1
Hi am new here, can anyone help me with my profile summary please 😢
- 3
Hi
- 3
#include<iostream. h>
.h