+ 4

Code coach problem Argentina failed in case 5

What's the problem in my code #include <stdio.h> int main() { int a,b; scanf("%d%d",&a,&b); b=b*50; if(a<b){ printf("Pesos"); }if(a>b){ printf("Dollars"); } return 0; }

28th Feb 2020, 9:32 AM
高于鈞
高于鈞 - avatar
9 ответов
+ 2
The thread where you also posted your question contains the fix for your code. Check Diego's answer. https://www.sololearn.com/Discuss/2125936/?ref=app
28th Feb 2020, 9:50 AM
Mihai Apostol
Mihai Apostol - avatar
+ 3
Mihai Apostol and 高于鈞 I am extremely sorry for my mistake. I didn't noticed it. Please forgive me @Mihai Apostol. 😔😔
29th Feb 2020, 2:40 PM
Tanmay Gupta
Tanmay Gupta - avatar
+ 2
Mihai Apostol I see. Thanks for the answer!
28th Feb 2020, 10:02 AM
高于鈞
高于鈞 - avatar
+ 2
高于鈞 Yes. In this multiplication causes overflow, Integer range exceeds. so disivion will work perfectly.. You can ask here directly, when some available here.. Posting others thread confused me... Ok..!
28th Feb 2020, 10:54 AM
Jayakrishna 🇮🇳
+ 2
Tanmay Gupta Hello Mihai Apostol just remind me that using int will overflow in case 5, it's just a hint.
28th Feb 2020, 1:39 PM
高于鈞
高于鈞 - avatar
+ 1
高于鈞 You're welcome.
28th Feb 2020, 10:03 AM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Jayakrishna After I changed b=b*50 to a=a/50 it's work.
28th Feb 2020, 10:41 AM
高于鈞
高于鈞 - avatar
0
Do you have any difficulty by this program? Is it still unsolved? Asking because you posted this in other thread..
28th Feb 2020, 10:25 AM
Jayakrishna 🇮🇳
0
//Let me code this.You can try this for your conditions// #include<stdio.h> int main() { int a, b; printf(" Enter A:%d"); scanf("%d",&a); printf("Enter B:%d"); scanf("%d",&b); a=a/50; b=b*50; if(a<b) { printf("Pesos"); } else { printf("Dollars"); } return 0; }
1st Mar 2020, 7:24 AM
nilay doshi
nilay doshi - avatar