Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How Do I fix it?

Hi so im watching Brackeys tutorial on how to code C# and im tackling a challenge he gave in one of his videos , I have my if and else statements and i think my syntax is good but i cant understand why it wont execute heres my code:

int input1;

            Console.WriteLine("Solve the following equation: 10 * 2+3");

            input1 = Convert.ToInt32 (Console.ReadLine() );

            if(input1 = 23 ) {

                Console.WriteLine("Correct");

            }

            else

            {

                Console.WriteLine("Incorrect");

            }

Best Answer

  • AarifAarif Member
    edited February 2022 Accepted Answer

     if(input1 = 23 )

    you are assigning "input1" variable the value of 23instead you need to compare the variable with 23.You need to use "==" double equal to for comparing expressions.

    Hope This helps You :)

Answers

Sign In or Register to comment.