+ 1
C# code not working!
I made a very basic c# code about a guessing game that uses if and Console.ReadLine. The concept is to guess the correct number and if it's less than the correct number, it tells you that. if its more, it tells you too. and finally if it's the same number stored in the code it tells you that you won. Here's my code: https://sololearn.com/compiler-playground/c4OwyD7UOY3R/?ref=app
2 Antworten
+ 4
Sees HM
It's only working when UserInput > 24
Because other conditions are inside the first one
You need to do it like this:
if (UserInput > 24)
{
Console.WriteLine("You lose: The correct number is less than your number");
}
else if (UserInput < 24)
{
Console.WriteLine("You lose: The correct number is greater than your number");
}
else
{
Console.WriteLine("You win: 24 was the correct number");
}
+ 2
Thanks! Binx