Two Expressions.

Q4. Given the two following expressions:

a.) val=3          b.) val= =3

i.) How are these two different?

ii.) What will be the result of the if the values of val is 5 initially?

Ans.

i.) The expression

a.) is an assignment expression.

b.) is a an relational expression that tests for equality.

ii.) The result of

a.) will be val having value 3 i.e., 3 and the result of

b.) will be boolean false because 5 is not equal to 3.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s