## Multiple Choice, 2 points each

On lynx, use down arrow to move to the next question or choice. Hit return to make your selection.

1. A function f which takes two integer parameters and does not return any value should have the function prototype:
a. f(int, int) ;
b. void f(int) ;
c. void f(int, int) ;
d. int f(void, void) ;

2. A break statement inside a case of a switch statement
a. causes the next case to be executed next.
b. causes the default case to be executed next.
c. causes the statement after the switch statement to be executed next.
d. causes the statement after the innermost loop to be executed next.

3. What is the output of the following code fragment?
int a = 3, b = 2 ;

if ( a < b ) {
printf("Dwarf Marigold\n") ;
} else if ( a < b + 2 ) {
printf("Purple Iris\n") ;
} else {
printf("Yellow Crocus\n") ;
}

a. Dwarf Marigold
b. Purple Iris
c. Yellow Crocus
d. No output is produced.

4. The expression 19/2
a. has type double and value 9.5.
b. has type int and value 9.
c. has type double and value 10.
d. has type int and value 10.

5. What is the value of the following expression?
1 * 2 + 3 * 4 - 5 + 6

a. 12
b. 13
c. 14
d. 15

6. Let flag be a Boolean variable. Note that there is an assignment in the condition of the if statement. The output of the following program fragment is:
flag = FALSE ;
if (flag = FALSE) {
printf("Zinnia") ;
} else {
printf("Petunia") ;
}

a. Zinnia
b. Petunia
c. FALSE
d. No output is produced.

7. What is the effect of the following code?
int i, total ;

total = 0 ;
for (i = 3 ; i <= 17 ; i += 3) {
total += i ;
}
printf("%d\n", total) ;

a. It prints out the integers from 3 to 17.
b. It prints out the multiples of 3 from 3 to 17.
c. It prints out the sum of the integers from 3 to 17.
d. It prints out the sum of the multiples of 3 from 3 to 17.

8. The following Boolean expression is equivalent to which of the given expressions?
!( (n > 17) && (n < 24) )

a. (n < 17) || (n > 24)
b. (n <= 17) || (n >= 24)
c. (n < 17) && (n > 24)
d. (n <= 17) && (n >= 24)

9. Considering short circuit evaluation, after executing the following statments,
int a ;
bool flag ;

a = 3 ;
flag = (7 > 1) || (a = 11) ;

a. flag is TRUE and a is 11.
b. flag is TRUE and a is 3.
c. flag is FALSE and a is 11.
d. flag is FALSE and a is 3.

10. What is the output of the following code fragment?
int a, b ;

a = b = 4 ;
a += b++ % 3 ;
printf("a = %d, b = %d\n", a, b) ;

a. a = 5, b = 4
b. a = 5, b = 5
c. a = 6, b = 4
d. a = 6, b = 5