New to c++ ,paint costs code coach | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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)

4th Nov 2021, 6:24 AM
Prabhas Koya
3 Respostas
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);
4th Nov 2021, 9:20 AM
AĶ¢J
AĶ¢J - avatar
+ 2
Prabhas Koya Cast with int cout << int(round((40 + 5 * a) * 1.1));
4th Nov 2021, 6:34 AM
AĶ¢J
AĶ¢J - avatar
+ 1
AĶ¢J - SĶŸoĶŸlĶŸoĶŸHĶŸeĶŸlĶŸpĶŸeĶŸrĶŸ Doesn't round produce an integral value
4th Nov 2021, 6:59 AM
Prabhas Koya