+ 1

What is wrong here?

I've just started and I'm doing a very basic math game for practice, but it doesn't work, any solution? This is the code: Console.WriteLine("Welcome to the Math game! n\ Q1: What is 3 * 8 + 1"); int result = Convert.ToInt16(Console.ReadLine()); if(result == "25") {Console.WriteLine("Correct!")}; else {Console.WriteLine("Incorrect!")};

2nd Mar 2022, 5:13 PM
Wiki
3 Respostas
+ 3
escape: n\ should be \n wrong place for ; they should be after ); not }; if(result == "25") , remove quotes. Console.WriteLine("Welcome to the Math game! \n Q1: What is 3 * 8 + 1"); int result = Convert.ToInt16(Console.ReadLine()); if(result == 25) { Console.WriteLine("Correct!"); } else { Console.WriteLine("Incorrect!"); }
2nd Mar 2022, 5:31 PM
Bahhaⵣ
Bahhaⵣ - avatar
+ 2
* the newline character is \n, not n\ * result == 25, not result == "25" as result is an integer * remove the ; before the else-statement
2nd Mar 2022, 5:36 PM
Lisa
Lisa - avatar
+ 2
Thanks to everyone! Solved
2nd Mar 2022, 5:53 PM
Wiki