0
Can you pls resolve it. It is showing error!!!
9 ответов
+ 6
By the way, Uma Raju
You should delete this question.
https://www.sololearn.com/Discuss/2657068/?ref=app
+ 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
+ 5
Uma Raju
Pleasure's all mine 😊
+ 2
https://code.sololearn.com/cDPWLyYU3t8U/?ref=app
you declared function inside main it's error check it
+ 1
Thank you Minho. I appreciate your teaching skills and time you have spent for my question.
0
But, it is not the second smallest number!!
0
Uma Raju I solved your error
0
Ya, but can please review my code and correct logical error.
0
I expecting second smallest number as output but it is displaying first smallest number !