+ 1
7 or 9.375
when i run this code the compiler give me the answer 7 but when i calculate it the result = 9.375 what is the right answer? #include <iostream> using namespace std; int main() { int x=3/2*4+3/8+3; cout<<x<<endl; return 0; }
2 ответов
+ 4
you need to use quite a bit of type-casting and store the result in a double to get your expected result.
0
i am still getting the same result 7
#include <iostream>
using namespace std;
int main() {
float x;
x=3/2*4+3/8+3;
cout<<x<<endl;
return 0;
}