C++ Questions

Well, I'm honestly am not sure what to make of these questions. I'm either missing something, or just really dumb. I have looked through my book and looked just about everywhere before finally posting on here. Please help!

In C++, what is the result of the following statement? 14 % 4 = 9
- What I don't get here is that 14%4 should equal 5... Not 9... So I don't know what they are asking here or what they want me to say. -

In C++, what is the result of the following statement? 5 / 2 = 11
- Again, not sure what they want me to say since 5/2 should actually equal 2.5... -

What is the output of the following code segment? int hours = 12; if (hours > 40)
{ cout << "Overtime Hours\n";}
- Here, they do not offer an input so really it would output nothing since the if statement will always be false. Right? Or am I missing something? -


Those are my questions. Please explain! Thank you!
Last edited on
14 % 4 = 9
5 / 2 = 11
These should both be compilation errors, you cannot assign to rvalues. Remember, = is the assignment operator!
Ok! So they are errors! Cool, glad I'm not going completely crazy. Any idea about the last question?
What is the output of the following code segment?
1
2
 int hours = 12; if (hours > 40) 
{ cout << "Overtime Hours\n";}

You're correct. Nothing would be output.
Thank you so much! :)
Topic archived. No new replies allowed.