Minimum of three numbers

• 7
• Locked
"Don't compare me with others!" she cried. But comparisons are unavoidable in this world. Especially in programming. Let's take three numbers, look at them, and figure out which one is the smallest. We'll do this using a program, more precisely, a special min method that calculates which number is smaller than the other two.
You can't complete this task, because you're not signed in.
Sergio
Level 3 , Beaverton, Spain
30 December 2022, 11:22
The key is to create two methods: min1() and min2() in order to compare one pair at time. Then compare two methods only.
Lunita
Level 4
27 December 2022, 20:39
Como lo logré:
``````if (a <= b && a <= c){
return a;
}
if (b <= a && b <= c){
return b;
}
if (c <= a && c <= b){
return c;
}
else
return 0;``````
Nuhazet
Level 4 , Santa Cruz de Tenerife, Spain
23 April 2022, 08:51
Si te está dando problemas esta tarea, prueba con comparar también por igualación ( a <= b && a <= b ) Mucho ánimo! If you are having problems with this task, try to compare also by equalization ( a <= b && a <= b ). Cheer up!
Lunita
Level 4
27 December 2022, 20:41
Eso fue lo que me funciono! Tambien poner
``return 0;``
al final de todo el bloque.
Jeongmin
Level 8 , Tsche-mul-p-ho, Korea, Republic of
23 September 2021, 11:55
It was tricky to achieve the goal using if, && operator, else if. There were two same values and it made my program working the wrong way. Instead, I took a two-step approach. First, compare a and b, then save min. Next, compare min and c.
Anonymous #10795220
Level 2 , Chicago, Argentina
23 August 2021, 00:13
1 -3 3 5 Esta es la salida cual es el error , por favor?
Steve C. Ands
Level 10 , Medellín, Colombia
16 November 2021, 21:52
Me sucede lo mismo el método está bien y sale eso. Y resulta en error.
Anonymous #10795220
Level 2 , Chicago, Argentina
23 August 2021, 00:12
No se que esta mal el resultado esta bien!!!
Víctor Alfonso Martínez Gómez
Level 3 , Manizales, Colombia
10 August 2021, 22:31
if (a
Víctor Alfonso Martínez Gómez
Level 3 , Manizales, Colombia
10 August 2021, 22:31
if (a una pequeña ayuda para iniciar su código.
Toka
Level 11 , Dugo Selo, Croatia
10 July 2021, 14:07
I solved the task with 2x Math.min() method and it works :)
4 June 2021, 15:56
i solved the task creating another method min(int a, int b). You can create a method who compare the values of "a" and "b" to see which of them is the minimum. After you can declare a new variable on method min(x, x,x) referenced to the previus method "m2 = min(x,x)" and do the comparation