+ 1
Whats wrong with this code? C#
I made a three number comparison program using C# using if-else if nested statements to practice nested statements. But when Z is the greatest number it doesn't seem to output that Here is the code on 'Code Playground'. https://code.sololearn.com/cyTpF4qarW1Q/#cs Can you tell me whats wrong with this code?
3 Respuestas
+ 24
Or this way
Lines 52-63
else if (x > y && x > z)
{
Console.WriteLine("X is greater than Y and Z");
}
else if (y > x && y > z)
{
Console.WriteLine("Y is greater than X and Z");
}
else if (z > x && z > y)
{
Console.WriteLine("Z is greater than X and Y");
}
+ 17
From line 60:
else if (y > x)
{
if (y > z)
{
Console.WriteLine("Y is greater than X and Z");
}
else
{
Console.WriteLine("z > y > x"); // Add this
}
}
+ 17
Also you've got more conditions to add similar to the one you missed already