Skip to main content

Section 5.6 Selection-WE3-P1

Subgoals for Evaluating Selection Statements.

  1. Diagram which statements go together
  2. For if statement, determine whether expression is true or false
  3. If true – follow true branch, if false – follow else branch or do nothing if no else branch

Subsection 5.6.1

Use this given setup
int alpha = 2;
int beta = 1;
int delta = 3;
int eta = 0;
int gamma = 0;

Exercises Exercises

1.
Q10: After executing the following code, the value in variable alpha is and the value in variable gamma is .
if (alpha > beta)
    alpha = alpha + 2;
if (alpha > delta)
    gamma = alpha + 5;
2.
Q10a: After executing the following code, the value in variable alpha is and the value in variable gamma is .
if ((alpha * beta) > delta)
    gamma = alpha * beta;
if (eta > (alpha / beta))
    eta = alpha / beta;
You have attempted of activities on this page.