Next: Exercises Up: The if statement Previous: Summary
Try to answer as many of the following Multi-choice questions as you can.
Do not panic if you make any errors. You can always start again by clicking on the "Restart" button, located at the bottom.
Please enter your full name :
If y has the value 5 what will be the value of the variable y after the following piece of C++ is executed?
y
if (y > 0) y += 2;
If p has the value 3 and max has the value 5, what will be the value of the variable max after the following piece of C++ is executed?
p
max
if (p < max) max = p;
If x has the value 5.0 what will be the value of the variable countneg after the following piece of C++ is executed?
x
countneg
countneg = 0; if (x < 0.0) negsum = negsum + x; countneg = countneg + 1;
If this is changed as follows what would be the value of countneg after execution of the code?
countneg = 0; if (x < 0.0) { negsum = negsum + x; countneg = countneg + 1; }
Once you have completed all the questions, and are quite happy with your answers. Then click on the "Submit Answers" button.
Clicking the "Restart" button will clear all your answers, ready to re-enter them.