|
|
|
June 21 - 26*, 2009
Required RockOn Pretest
Must be completed by May 1, 2009
This pretest is
designed for us to determine your knowledge and experience with C and C++
programming. To brush up on C concepts, there are numerous tutorials
online, including one at
http://www.cprogramming.com/tutorial.html#ctutorial.
Concepts included on this pretest: Variables, Conditional Control
(if-else), Loops (while, for), Functions, Arrays, Bitwise Operators
(&, |, ^, ~, <<, >>), Pointers, C-Strings, and #define, #include.
Time is very critical during this workshop and
we need everyone on the same level as much as possible. Good luck.
You may download a MS Word version of this test to practice but all tests
must be submitted via this page. You do not need to score 100% on this
test but try to get them all right:)
|
| Name: |
|
|
| Registration Number: |
|
|
| Email Address: |
|
|
| 1.
Which of the following C statements declares an integer variable named
my_int and assigns it a value of 42? |
|
|
| 2. What is
the value of output after the loop is executed?
int i;
int output;
output = 1;
for (i = 0; i < 30; i = i + 3)
{
if (i < 15)
{
output = output * 2;
}
else
{
output = output 2;
}
}
|
|
|
Questions
3 and 4 refer to the function foo, defined below:
int foo(double a, char b, long c);
|
|
|
| 3. What is
the return type of foo? |
|
|
| 4. Which
of the following statements correctly calls foo and assigns the return value
to the variable x (ignore the type of x for this question)? |
|
|
| 5. What
value is contained in x[3] after the following code is executed?
int x[10];
for (int i = 0; i < 10; ++i)
{
x[10-i] = i + 1;
}
|
|
|
| 6. What is the value of output
after the following code is executed?
int output;
int a = 10, b = 1, c = 4, d = 7;
if ((a < b) || ((b < c) && (d >= b)))
{
output = 1;
}
else
{
output = 0;
}
|
|
|
| 7. Which
of the following logical expressions evaluates to 1 for the given values?
A = 2;
B = 0;
C = 0;
D = 1;
E = 3;
|
|
|
| 8. Given a
function void foo(int x), which of the following correctly calls foo? |
|
|
| 9. Locate
and identify (1, 2, 3, or 4) the error in the following code:
char test;
scanf(test);
1. switch (test)
{
2. case a:
printf(Hello!);
break;
3. case b:
printf(Goodbye!);
break;
4. default:
printf(Input is not a or b);
break;
}; |
|
|
| 10. Which of the following is
not a valid variable declaration?
|
|
|
| 11. What
is the value of output after the following code is executed?
char mask = 0xAA;
char x = 0x13;
output = (x & mask) ^ 0x08;
|
|
|
| 12. What is the type of the
first parameter of the function foo, which is called with the statement
foo(&x);
where x is a char* variable.
|
|
|
| 13. Given
the struct below, how would the third element of the data array of the
struct be accessed?
struct my_struct
{
int key;
char data[100];
long extra;
} x;
|
|
|
| 14. Which of the following
statements allows the identifier MYNUM to be used to represent the constant
value 42? |
|
|
| 15. Which
of the following is NOT a valid C keyword? |
|
|