Open Source magazine on E-Technology

Page 15

option 1 is the correct answer.

Most of you will think of the 3rd option because you can see the condition is not true and hence the statement under if will not execute. Your concept is not wrong, you are right here but probably you miss the semicolon that is placed just after if statement in the programs. if statement ends here and the followed lines are not under the if statement, it's a free line and it's execution does not depend on any conditional statement.

If your answer is 3, probably you missed the ' = ' assignment operator in the if statement. it's not conditional operator, so it will not compare the values but it will assign the constant at right hand side to the variable at left hand side and hence the value that come in ' if statement ' is a nonzero value hence this program will print something.

If your answer is 1, I would like to congratulate you because you noticed the '=' assignment operator in the if statement but there is one thing that you forget that assignment operator not only make the if statement un-effective but also update the value of c from 'a' to 'b' and hence the option 2 is the correct answer.

if your answer is 1. probably you do not know anything about if statement otherwise you will never select this option,


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.