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 🙏🙏

1st Jul 2021, 5:46 PM
Jainil Raval
Jainil Raval - avatar
11 Respostas
+ 5
Krishnendu Dey Use ceil instead of round because you need nearest whole positive number. cout<<int(ceil(c));
1st Jul 2021, 5:53 PM
A͢J
A͢J - avatar
+ 8
int d = round(c); cout<<d;
1st Jul 2021, 6:02 PM
Simba
Simba - avatar
+ 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
1st Jul 2021, 6:15 PM
A͢J
A͢J - avatar
+ 4
🅰🅹 🅐🅝🅐🅝🅣 Thank you dude for helping 😀 I'm greatful to u 🙏🙏
1st Jul 2021, 6:11 PM
Jainil Raval
Jainil Raval - avatar
+ 4
1st Jul 2021, 6:18 PM
Jainil Raval
Jainil Raval - avatar
+ 3
Simba Thanks for the answer. But still confused how 'int' makes the difference ?
1st Jul 2021, 6:26 PM
Jainil Raval
Jainil Raval - avatar
+ 2
🅰🅹 🅐🅝🅐🅝🅣 Btw can u please tell what's the difference between 'ceil' and 'round ' ?
1st Jul 2021, 6:14 PM
Jainil Raval
Jainil Raval - avatar
+ 2
Benjamin Ansah What is the problem? And please make new question. Don't post in others question.
3rd Jul 2021, 2:04 AM
A͢J
A͢J - avatar
- 1
Hi am new here, can anyone help me with my profile summary please 😢
3rd Jul 2021, 2:00 AM
Benjamin Ansah
- 3
Hi
3rd Jul 2021, 3:08 PM
I'm BHAVESH
I'm BHAVESH - avatar
- 3
#include<iostream. h> .h
3rd Jul 2021, 4:41 PM
Rudra prasad Barik