Suppose that x, y, z and w are int variables and x = 25, y = 3, z = 12 and w = 4
ID: 3712463 • Letter: S
Question
Suppose that x, y, z and w are int variables and x = 25, y = 3, z = 12 and w = 4. What is the output of the following statements? a. cout << "x == z: " << ( x == z ) << endl, b. cout << "y != z - 9: " << (y != z - 9 ) << endl; c. cout << "x - y == z + 10: " << (x - y == z + 10 << endl; d . cout << "! (z < w ) :" << ! (z < w ) << endl; e. cout << "w - y < x - 2 * z: " << ( w - y < x - 2 * z) << endl;
Explanation / Answer
Given x = 25,y = 3, z = 12 and w = 4
a. cout << "x==z:" << (x == z)<<endl;
it prints as : x==z:0 (as x = 25 and z = 12 condition fails and prints 0)
b. cout<<"y!=z-9:"<<(y!=z-9)<<endl;
it prints as : y!=z-9:0 (as y = 3 and z-9 = 3 then condition 3!=3 will be false hence 0)
c. cout<<"x-y == z+10:"<<(x-y == z+10) << endl;
it prints as : x-y == z+10:1 (as x-y = 22 and z+10 = 22 so 22 ==22 is true hence 1)
d. count<<"!(z<w):"<<!(z<w)
it prints as : !(z<w):1 (as z<w is false it will be 0 and then not of 0 is 1 hence 1)
e. cout<<"w-x<x-2*z:"<<(w-x<x-2*z)<<endl;
it prints as : w-x<x-2*z:1(as w-x = -21 and x-2*z = 1 so -21<1 as it is true hence 1)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.