Next: The if statement Up: Conditions Previous: Multiple Choice Questions

Review Questions

  1. What are the relational operators?
  2. Write a relational expression which would evaluate to true if the sum of variables x and y was equal to the value of a variable z.
  3. Bracket the following logical expressions to show the order of evaluation of the operators. Hence if a is 5, b is 10, c is 15 and d is 0 what are the truth values of the expressions?
    c == a+b
    a != 7
    b <= a
    a > 5
    a+d >= c-b
    d/a < c*b
    
  4. Bracket the following logical expressions to show the order of evaluation of the operators. Hence if a is 5, b is 10, c is 15 and d is 0 what are the truth values of the expressions?
    c == a+b || c == d
    a != 7 && c >= 6 || a+c <= 20
    !(b <= 12) && a % 2 == 0
    !(a >5) || c < a+b
    

  5. Write a logical expression which returns true if a float variable x lies between -10.0 and 10.0.



Next: The if statement Up: Conditions Previous: Multiple Choice Questions