On lynx, use down arrow to move to the next question or choice.
Hit return to make your selection.
- In the following code fragment, the Boolean expression in the if
statement contains an assignment. What output is produced?
int x = 1, y = 2 ;
if ( (x = 5) > y )
printf("%d\n", x ) ;
else
printf("%d\n", x + y) ;
a. 1
b. 3
c. 5
d. 7
Your Answer:
- Which of the given expressions is equivalent to the
following expression for all values of the integer
variable i ?
(i <= 63) && (i >= 51)
a.
!( (i > 63) || (i < 51) )
b.
!( (i > 63) && (i < 51) )
c.
( (i > 63) || (i < 51) )
d.
( (i &tl;= 63) || (i >= 51) )
Your Answer:
- Which of the following is a function prototype of a function
that takes two parameters, an integer and a pointer to an integer, and
returns an integer value?
a.
void f (int, int) ;
b.
int *f (int, int *) ;
c.
int f (int *, int *) ;
d.
int f (int, int *) ;
Your Answer:
- After the declaration:
struct {
int part1 ;
int part2 ;
} foo ;
a.
foo is a new data type which can be used to declare
variables as pointers to a record.
b.
foo is a new data type which can be used to declare
variables as records.
c.
foo is a variable which can hold a pointer to a record.
d.
foo is a variable which can hold a record.
Your Answer:
- Suppose that p is a pointer to double and that
sizeof(double) is 8. Then the expression p = p + 2;
a.
Adds 2 to p
b.
Adds 2.0 to the double variable that p points to.
c.
Adds 16 to p
d.
Adds 16.0 to the double variable that p points to.
Your Answer:
- According to the rules of short circuit evaluation, after the
following code fragment is executed
bool flag = FALSE ;
int a = 1 ;
flag = (a > 1) || ( (a = a + 5) > 4 )
a.
flag is FALSE and a is 1.
b.
flag is FALSE and a is 6.
c.
flag is TRUE and a is 1.
d.
flag is TRUE and a is 6.
Your Answer:
- In C programming, a recursive function is a function that
a.
is written by hand in pseudo-code.
b.
makes function calls to many other functions.
c.
makes function calls to itself.
d.
makes function calls to main.
Your Answer:
- To store the string "CMSC201" you need to allocate:
a.
7 bytes of memory
b.
8 bytes of memory
c.
14 bytes of memory
d.
16 bytes of memory
Your Answer:
- The expression 17/8
a.
has type double and value 2.125
b.
has type int and value 2.125
c.
has type double and value 2.0
d.
has type int and value 2
Your Answer:
- What is the value of the following expression?
6 - 5 - 4 * 3 / 2 + 1
a.
-3
b.
-2
c.
6
d.
-4
Your Answer:
- What is the effect of the following code?
int i, sum ;
sum = 1 ;
for (i = 2 ; i <= 5 ; i++) {
sum = sum + i ;
}
printf("%dn", sum) ;
a.
It prints out the numbers from 1 to 5.
b.
It prints out the numbers from 2 to 5.
c.
It prints out the sum of the numbers from 1 to 5.
d.
It prints out the sum of the numbers from 2 to 5.
Your Answer:
- What is the output of the following code fragment?
int n, *p ;
n = 2 ;
p = &n ;
*p = 4 ;
n = *p * n ;
printf("%d %d\n", *p, n) ;
a.
4 8
b.
4 16
c.
8 16
d.
16 16
Your Answer:
To submit this section for grading click here: