Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ Assuming a and b are variables. The code fragment: a = b; will give the s

ID: 3911469 • Letter: I

Question

In C++

Assuming a and b are variables. The code fragment:

a = b;

will give the same result as:

a == b;

True or False

Rewrite the following expressions using and if...else statement. Assume that all variables are defined properly. Note: your expressions should be syntactically correct (i.e they should compile without errors).

x < 5 ? y = 10 : y = 20;

fuel >= 10 ? drive = 150 : drive = 30;

booksBought >= 3 && booksBought <= 30 || booksBought % 3 ? discount = 0.15 : discount = 0.0;

Relational and equality operators cannot be used for the string data type. True or False

Given that count is 28. The expression:

if (16 < count < 25)

evaluates to false.

True or False

Explanation / Answer

Q) Assuming a and b are variables. The code fragment:

a = b;

will give the same result as:

a == b;

True or False?

Ans:-  False, a=b; means value of variable b is assigned to variable a.

a==b; is a Boolean expression, It always checks whether given expression is True or False. If a is equal to b then it is True and it returns 1 else False and returns 0.

Example:- if int a=10 , b=20;

a=b;

i.e. now a=20;

and a==b;

i.e 1 (True)

not the same result.