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

Suppose x = 3 and y = 2; show the output, if any, of the following code. What is

ID: 3618353 • Letter: S

Question

Suppose x = 3 and y = 2; show the output, if any, of the following code. What is the output if x = 3 and y = 4? What is the output if x = 2 and y = 2?

Explanation / Answer

   case 1 :                 when x=3 and y=2 ;                  The first if condition (x>y) is satisfied and it enters in . Butthe second if condition (y>2) is not satisfied . so nooutput is generated . case 2:    when x=3 andy=4 The firstif condition is not satisfied so it enter the else and prints thevalue of x; output isx=3; case 3 :                when x=2 and y=2 ;                The first if condition is not satisfied so it enter the else andprints the value of x; output isx=2;