+ 2
What's wrong? C++ | Argentina challenge
Can you please help me? I tried to figure it out what's wrong and I don't understand what #include <iostream> using namespace std; int main() { long long d=p*0.02; long long p; cin>>d; cin>>p; if(d>p) { cout<< "Pesos" << endl; } else { cout<< "Dollars" << endl; } return 0; }
8 Answers
+ 1
you are assigning p*0.02 to d before p is given any value.
(not saying it is the only issue.)
+ 1
bahhaš§ LOL, okey. But still not correct at all 5 code tests
+ 1
If bahhaš§ doesn't mind if I jump in
Dolev Kashi use division by 50 as the multiply causes overflow in this challenge case.
+ 1
Mihai Apostol What do you mean by 'overflow'? And why dividing specifically by 50?
+ 1
sarada lakshmi For the sake of correctness, check this:
https://en.cppreference.com/w/cpp/language/types
0
Dolev Kashi
I remembered a little bit wrong.
There was a thread about either multiplying pesos with 50 or dividing dollars by 50. Multiplying in that case was causing overflow because one of the test cases uses a large value for pesos. I will update this answer when I'll find that thread.
You were right dividing by 50 or multiplying with 0.02 are basicaly the same thing. (1/50 = 0.02)
Anyhow, did you manage to solve the challenge?
Edit: added two similar threads
https://www.sololearn.com/Discuss/2125936/?ref=app
https://www.sololearn.com/Discuss/2146013/?ref=app
0
There is no datatype like long long... It's either signed long long int or unsigned long long int... That's why you are getting an error..Now, after modification you'll get the correct output... Once check it out š
0
multiply it to 0.5 or 0.2