Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. For what exact range of values of variable x does the following code segment

ID: 3537690 • Letter: 1

Question

1. For what exact range of values of variable x does the following code segment print 'C'?
if (x <= 200="" br="" _prototypeuid="15">     if (x < 100)
          if (x <= 0="" br="" _prototypeuid="17">               cout << 'A';
          else
               cout << 'B';
     else
          cout << 'C';
else
     cout << 'D';


A. e. 100 < x <= 200="" label=""> B. x <= 0="" br="" _prototypeuid="46"> C. 0 < x < 100
D. x > 200 E. 100 <= x="" 200="" br="" _prototypeuid="69">

Explanation / Answer

1) For output A, x<=0

For output B, 0<x<100

For output C, 100<=x<=200

For output D, x>200


So for output C, x should be from 100 to 200 with both 100 and 200 included.

Option would be E.


2)The if condition shows i should be even to add to s


Option C gives the correct interpretation that sum of even number form n down to 1


3)in the while loop there is no bracet to include bothe statements otherwise it takes only one statement to be in while loop. and output should be i rather than x.


The answer should be


i=0;

while(i<n)

{

cout<<i<<endl;

i++;

}


4) here, s = 0 and i = n before while loop.

So i starts from n and the condition in while loop is i!=0 which says that that while loop runs till i becomes 0


So ansewr would be option A, sum of all integers from n down to 1