+ 1

what is the problem of this code

pls solve the problem #include<stdio.h> int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); if(a<b) { if(a<c) { printf("%d", a); } else { printf("%d", c); } } else { if(b<c) { printf("%d", b); } else { printf("%d", c); } } }

27th Dec 2020, 2:34 PM
Nadeem
Nadeem - avatar
3 ответов
+ 1
Seems to be working fine though The output is the minimum value right? For example: INPUT: 4 1 7 OUTPUT: 1 https://code.sololearn.com/crl0mS3e5Wsu/?ref=app
27th Dec 2020, 2:45 PM
noteve
noteve - avatar
+ 2
#include<stdio.h> int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); if(a<b && a<c) { printf("%d", a); } else if (b<a && b<c) { printf("%d", c); } else { printf("%d", c); } return 0; }
27th Dec 2020, 2:46 PM
KRITI
KRITI - avatar
+ 2
You should use if-else-if condition in such type of code ... Hope it will be helpful to you
27th Dec 2020, 2:47 PM
KRITI
KRITI - avatar