Question: 4. Predict the output from the following code segments: (2 x 10 = 20 points) a) int X; cin >> X; switch(X % 5) {
4. Predict the output from the following code segments: (2 x 10 = 20 points) a) int X; cin >> X; switch(X % 5) { case 4: cout << X 2 << endl; break; case 0: cout << 2 * X << endl; case 2: cout << X/2 << endl; break; default: cout << X + 2 << endl; } i) X = 9 ii) X = 20 iii) X = 3 b) Given the values of x, y, z, what will be the values of x, y and z after executing the following code? if (y == 0 || z != 0) { if(z <= 2) { z = 4; } } else { y = 5; z = y + x; } i) Given: x = 4, y = 0, z = 3 ii) x = 3, y = 2, z = 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
