[SOLVED] COMP2113- Module 3

24.99 $

Category:

Description

5/5 - (1 vote)

 

  1. Evaluate the following expressions:
    1. 36 / 5
    2. 18 − 32 / 6 * 3
    3. 6 − 8 % 11
    4. 0 / 5
    5. 25 − 7 % 3 + 8 / 3
    6. 0 + 5.0 * 3.0 / 4.0
  2. Suppose x, y, and z are int variables and x = 2, y = 5, and z = 6. What is the output of each of the following statements?
    1. cout << “x = ” << x << “, y = ” << y << “, z = ” << z;
    2. cout << “Sum of ” << x << ” and ” << z << ” is ” << x + z;
    3. cout << “2 times ” << x << ” = ” << 2 * x;

 

  1. The following program has syntax mistakes. Correct them. On each successive line, assume that any preceding error has been corrected.

 

const char = STAR = ‘*’ const int PRIME = 71; int main {

int count, sum;  double x;    count = 1;  sum = count + PRIME;    x := 25.67;       newNum = count * ONE + 2;     sum + count = sum;  x = x + sum * COUNT;

cout << ” count = ” << count << “, sum = ” << sum

<< “, PRIME = ” << Prime << endl;

}

  1. Suppose a, b, and c are int variables and a = 5 and b = 6. What value is assigned to each variable after each statement executes? If a variable is undefined at a particular statement, report UND (undefined).
a b c
a = (b++) + 3;
c = 2 * a + (++b);
b = 2 * (++c) – (a++);

 

 

 

Self-Review Exercise                                                                     Module 3                                                                                                 p. 1/1