Chapter 4 Quiz Starting Out With C++ 013

Let's analyze the following statement assuming that y is 6.

if ( y = 7 )
   cout << " y is 7.  How lucky of you. ";
else
  cout << "y is not 7.  Sorry about that.";

What will be the result of this section of code.

a.  cout << "y is not 7.  Sorry about that.";
b. cout << " y is 7.  How lucky of you. "; //will always execute regardless of the value of y
c. y=7 is an assignment and not a comparison will not compile
d. I was texting in class and have no absolutely no idea.
e. This will compile but completely skip both statements.

1 comment:

  1. b. cout << " y is 7. How lucky of you. "; //will always execute regardless of the value of y

    ReplyDelete