What's wrong? C++ | Argentina challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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; }

20th Feb 2020, 11:21 AM
Dolev
Dolev - avatar
8 Answers
+ 1
you are assigning p*0.02 to d before p is given any value. (not saying it is the only issue.)
20th Feb 2020, 11:37 AM
Bahhaⵣ
Bahhaⵣ - avatar
+ 1
bahha🐧 LOL, okey. But still not correct at all 5 code tests
20th Feb 2020, 11:43 AM
Dolev
Dolev - avatar
+ 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.
20th Feb 2020, 11:48 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Mihai Apostol What do you mean by 'overflow'? And why dividing specifically by 50?
20th Feb 2020, 1:50 PM
Dolev
Dolev - avatar
+ 1
sarada lakshmi For the sake of correctness, check this: https://en.cppreference.com/w/cpp/language/types
22nd Feb 2020, 9:44 AM
Mihai Apostol
Mihai Apostol - avatar
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
20th Feb 2020, 2:01 PM
Mihai Apostol
Mihai Apostol - avatar
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 👍
22nd Feb 2020, 9:41 AM
sarada lakshmi
sarada lakshmi - avatar
0
multiply it to 0.5 or 0.2
4th May 2020, 3:28 PM
Epsilon ︻╦̵̵͇̿̿̿̿╤──
Epsilon ︻╦̵̵͇̿̿̿̿╤── - avatar