2_Questions_5_3_if_switch-1

# 2_Questions_5_3_if_switch-1 - CIS 15AG 1 Questions Chapter...

This preview shows pages 1–3. Sign up to view the full content.

CIS 15AG Questions Chapter 5: Selection – Making Decisions (nested ifs and switch) 28. Predict the output if (a > 0) if (a < 100) { r = 10; if (a < 50) r = 20; } else r = 30; else r = 40; printf("%d", r); 29. Predict the output r = 30; if (a > 0) { if (b > 0) r = 50; } else r = 80; printf("%d", r); 30. Predict the output r = 30; if (a > 0) if (b > 0) r = 50; else r = 80; printf("%d", r); 1 a Output 50 -50 25 100 a b Output 10 10 10 -2 -2 10 -2 -2 a b Output 10 10 10 -2 -2 10 -2 -2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CIS 15AG Questions Chapter 5: Selection – Making Decisions (nested ifs and switch) 31. What happens when = is used instead of == ? r = 30; if (a == b) if (a > 0) r = 50; else r = 80; printf("%d", r); r = 30; if (a = b) if (a > 0) r = 50; else r = 80; printf("%d", r); 32. Rewrite the following fragment of code using proper indentation, then predict the output. x = 10; y = 20; z = 30; if (x > y){x = y; z += 50;}else if(x < 25) {x += 5; y -= 5; z *= 5;} else z = 0; printf("%d %d %d", x, y, z); 2 a b Output 5 5 5 -5 -5 -5 a b Output 5 5 5 -5 -5 -5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

2_Questions_5_3_if_switch-1 - CIS 15AG 1 Questions Chapter...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online