0

What's wrong with my logic?

https://www.sololearn.com/coach/23?ref=app It's showing 5th test case failed. Code is given below👇 https://code.sololearn.com/cfnIgVc6n5AM/?ref=app

12th Oct 2020, 1:49 AM
Samia Haque
Samia Haque - avatar
5 Respostas
+ 3
Samia Tisha At line 11 dollar variable will overflow when the input is too big. Try using long type. https://en.m.wikipedia.org/wiki/Integer_overflow else { return 0; } //You should remove this, it's unnecessary and will make the last line of the function body to be unreachable else if(peso<dollar){ printf ("Pesos\n"); } That's redundant and could have been written as: else { printf("Pesos\n") }
12th Oct 2020, 2:26 AM
Kevin ★
+ 2
Try remove the else and change the if else to else. If prices are same you code will bug cause will be none of them.
12th Oct 2020, 2:04 AM
Marcelo Anjos
Marcelo Anjos - avatar
+ 1
i get it somehow hard to understand your quiz because i see all it is okay
12th Oct 2020, 2:00 AM
Obiri Sacalivin
Obiri Sacalivin - avatar
+ 1
Not wrong, but tip to be "faster". You can multiple pesos by 0.02 and them don't need multiply dollar by 100. Can work with decimals too. edited: that's the problem. I changed and works.
12th Oct 2020, 2:05 AM
Marcelo Anjos
Marcelo Anjos - avatar
+ 1
Kevin ★ Now I understand the problem. Thank you😊
12th Oct 2020, 3:02 AM
Samia Haque
Samia Haque - avatar