Answer to Question #23966 in C++ for Nourh

Question #23966
2. What does the following code output?
int c = 4;
if (c % 2 == 0) {
c += 1;
}
cout << c << endl;
1
Expert's answer
2013-02-08T04:27:04-0500
int c = 4;
sets integer value c equal to 4;

if(c % 2 == 0) {
if c is divisible by 2

c += 1;
add 1 to c (so c is equal to 5)

cout<< c << endl;
outputs c on screen

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS