Multiple choice

Find out the error in following block of code. If (x = 100) cCout << “x is 100” ;

  1. 100 should be enclosed in quotations.

  2. There is no semicolon at the end of first line.

  3. “Equals to” operator mistake.

  4. Variable x should not be inside the quotation.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The code uses assignment operator (=) instead of equality comparison operator (==). In C, the expression if (x = 100) assigns 100 to x and the condition always evaluates to true (non-zero), whereas if (x == 100) properly compares x with 100. This is a common programming error.