0

Can you pls resolve it. It is showing error!!!

https://code.sololearn.com/cGgsZ2NH1OZc/?ref=app

7th Jan 2021, 4:02 AM
Uma Raju
Uma Raju - avatar
9 Respuestas
+ 6
By the way, Uma Raju You should delete this question. https://www.sololearn.com/Discuss/2657068/?ref=app
7th Jan 2021, 4:39 AM
Minho
Minho - avatar
+ 5
Uma Raju Just take out your notebook and write what's happening.. Only then you can understand what's going wrong. Let's understand with an example a = 1, b = 2 and c = 3 First you wrote, third = Math.max(a,b); = Math.max (1,2) So, third = 2; Next you wrote, third = Math.max(third,c); = Math.max(2,3) = 3 Now, third = 3 (You found the max value!) But then you wrote, ⚠️ first = Math.max(a,b); = Math.max(1,2) Which makes first = 2 /*** This is the line where you went wrong. You should find the minimum of a and b. Since we are now interested to find the minimum of three numbers. Change this line to, first = Math.min(a,b) And your problem will be solved. */ And then, first = Math.min(first,c); = Math.min(2,3) = 2 So first is 2. Now when you're doing, sec = (a+b+c) - (first + third); It simply does, (1+2+3) - (3+2) = 1
7th Jan 2021, 4:36 AM
Minho
Minho - avatar
+ 5
Uma Raju Pleasure's all mine 😊
7th Jan 2021, 4:49 AM
Minho
Minho - avatar
+ 2
https://code.sololearn.com/cDPWLyYU3t8U/?ref=app you declared function inside main it's error check it
7th Jan 2021, 4:09 AM
Shahghasi Adil
Shahghasi Adil - avatar
+ 1
Thank you Minho. I appreciate your teaching skills and time you have spent for my question.
7th Jan 2021, 4:45 AM
Uma Raju
Uma Raju - avatar
0
But, it is not the second smallest number!!
7th Jan 2021, 4:16 AM
Uma Raju
Uma Raju - avatar
0
Uma Raju I solved your error
7th Jan 2021, 4:17 AM
Shahghasi Adil
Shahghasi Adil - avatar
0
Ya, but can please review my code and correct logical error.
7th Jan 2021, 4:18 AM
Uma Raju
Uma Raju - avatar
0
I expecting second smallest number as output but it is displaying first smallest number !
7th Jan 2021, 4:21 AM
Uma Raju
Uma Raju - avatar