Assignment 3: Exercise 0 (6 Points - 1 Point Per Question - No Program Required)
Assignment 3: Exercise 0 (6 Points - 1 Point Per Question - No Program Required)
Assignment 3: Exercise 0 (6 Points - 1 Point Per Question - No Program Required)
C/C++ Programming I
1. What is output: printf( "%d\n", !(6/3+2.2) + 3); (Notes 3.17 & 3.18)
(Note 3.2) A. value = 4 illegal switch value Got an 'A'
A. 3 B. value = 4
B. 7.2 C. illegal switch value
C. The output is implementation D. Got an 'A'
dependent. E. The output is implementation
D. 7 dependent.
E. garbage because the expression is type
double but %d specifies type int 4. What gets printed by:
putchar('A') + putchar('B');
2. Predict the output from: (Note 3.3)
if (5 < 4) A. AB only
if (6 > 5) B. BA only
cout.put('1'); C. either AB or BA
else if (4 > 3) D. either A or B but not both
cout.put('2'); E. A only
else
cout.put('3'); 5. What gets printed by:
cout.put('4'); putchar('A') && putchar('B');
(Note 3.15) (Note 3.3)
A. 4 A. AB only
B. 2 B. BA only
C. 24 C. either AB or BA
D. 4 or 24 depending upon D. either A or B but not both
implementation E. A only
E. Nothing is printed.
6. For int x = 5; what is the value and data type
3. Predict the output from: of the entire expression on the next line:
switch (2 * 2) sqrt(9.0), ++x, printf("123"), 25
{ (Note 3.11)
case 1+1: cout << "value = 2 "; A. 3.0 (type double)
case 29: cout << "value = 29 "; B. 3 (type int)
case 4: cout << "value = 4 "; C. 25 (type int)
default: cout << "illegal switch value "; D. 6 (type double)
case 'A': cout << "Got an 'A' "; E. implementation dependent
}