Starting from:

$40

ENGG1340 Computer Programming II Module 3 Self-Review Exercise Solved

ENGG1340 Computer Programming II Module 3 Self-Review Exercise
 

1.    Evaluate the following expressions: 

a)              36 / 5              

b)              18 − 32 / 6 * 3 

c)               6 − 8 % 11 

d)              22.0 / 5 

e)              25 − 7 % 3 + 8 / 3 

f)               18.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? 

a)              cout << "x = " << x << ", y = " << y << ", z = " << z; 

b)              cout << "Sum of " << x << " and " << z << " is " << x + z; 

c)               cout << "2 times " << x << " = " << 2 * x; 

 

3.    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; 

}  

4. 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++) + 3; 
 
 
 
c = 2 * a + (++b); 
 
 
 
b = 2 * (++c) - (a++); 
 
 
 
 

 

 

Self-Review Exercise                                                    Module 3                                                                         p. 1/1

 

More products