+ 2
New to c++ ,paint costs code coach
#include <iostream> #include <math.h> using namespace std; int main() { int a; cin>>a; cout <<round((40+5*a)*1.1); return 0; } Failing in last test case ( In python I did the same way and passed)
3 Réponses
0
Prabhas Koya
It returns integral value but as a floating-point value but need as a integer so we need to cast with int or you can assign result to int then print int value.
int d = round((40 + 5 * a) * 1.1);
cout << d;
here is round function in c++:
double round (double x);
float round (float x);
long double round (long double x);
double round (T x);
+ 2
Prabhas Koya
Cast with int
cout << int(round((40 + 5 * a) * 1.1));
+ 1
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟
Doesn't round produce an integral value