64 584
Assignments Done
99,2%
Successfully Done
In September 2018

Answer to Question #23965 in C++ for Nourh

Question #23965
3. What is output by the following code?
int c = 4;
int d = 5;
if ((d > c) && (d % 2 == 0)) {
cout << “Elvis is alive.” << endl;
} else {
cout << “Elvis is with Mama Kass.” << endl;
}
Expert's answer
int c = 4;
int d = 5;
if ((d > c) && (d % 2 == 0))
& cout << "Elvis is alive." << endl;
else
& cout << "Elvis is with Mama Kass." << endl;
&
The output of this code is:

Elvis is with Mama Kass.

because the 'if' condition is false:
(d > c) = (5 > 4) ~ true
(d % 2) = (5 % 2) = 1, (1 == 0) ~ false

(true && false) = false,
so the 'else' code branch is executed.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions