COP 3223 – C Programming
About Exam 1
Exam 1 is a multiple-choice questions exam, and it is a paper-based
test (No electronic devices will be permitted in Exam 1. All you need
to bring is your UCF id, a pencil and a UCF scantron sheet). In each
question, a block of code will be provided, and your job is to walk
through the code to understand it, determine the values of the
variables being used and to find out what is printed to the screen.
There will be NO syntax questions; the code snippet provided in each
question is supposed to compile with no syntax errors. The #include
directives, int main () {, return 0; and the ending } will be omitted
in each question.
Below is NOT exam1. It is a practice exam for you to have a very good feel
of what to expect. It is highly recommended that you try the questions on
paper first before you test them on the computer. Expect around 30
questions in Exam1.
Exam1 will be on everything up to (and including) loops. More specifically,
you should know these:
1) Declaration and initialization of variables
2) Different data types : int, float, char
3) printf and scanf
4) Conversion specifiers (%d for int, %c for char and %f for float)
5) Arithmetic and other operators (++, --, ==, !=, >, >=, <, <=, &&,| |,%)
6) Integer division
7) The if-else statement
8) The switch statement
9) Loops
10) The break and continue keywords
Sample Exam format and Questions
First Name: Last Name: UCF ID#:
UCF – COP 3223 - Exam 1—VERSION A
NOTE WELL: Assume that the code in each question has no syntax errors.
1 - What does the code print to the
screen?
int x = 1, y = 2 , z = 3; a) x is 1
b) x is 2
printf("x is %d", z); c) x is 3
x = y; d) None of the above
2 - What does the code print to the
screen?
a) x is 1
int x = 1, y = 2 , z = 3; b) x is 2
c) x is 3
x = y; d) None of the above
printf("x is %d", (z+y-1)/x+x);
3 - What does the code print to the
screen?
a) x++ is 1
b) x++ is 2
int x = 1; c) x++ is 3
d) None of the above
++x;
printf("x++ is %d", x);
4 - What does the code print to the
screen?
int x = 100; a) 100
printf("printf(x);"); b) printf(100)
c) printf(x);
d) None of the above
5 - What does the code print to the
screen? a) It is normal to mess up!
b) It is ormal o mess up!
printf("It is \normal \to mess up!"); c) It is
ormal to mess up!
d) None of the above
6 - What does the code print to the
screen?
a) 7/3
b) 3
printf("%d", 7/2); c) 3.5
d) None of the above
7 – What does the code print to the
screen?
float x = (float) 7/3; a) 7/3
b) 2.50
printf("%.2f", x); c) 2.00
d) None of the above
8 - What does the code print to the a) TRUE
screen? b) FALSE
c) TRUEFALSE
d) None of the above
int x = 3;
if ( x > 3 || x != 2 ) printf("TRUE");
printf("FALSE");
9 - What does the code print to the
screen?
a) TRUETRUE
int x = 3; b) TRUE
c) TRUETRUETRUE
switch ( x + 1) d) TRUETRUETRUETRUE
{ e) None of the above
case 3: printf("TRUE");
case 4: printf("TRUE");
default: printf("TRUE");
}
printf("TRUE");
10 - What does the last printf in this
code print to the screen?
int n = 0; a) n = 7
for(n = 7; n<0; n--) b) n = 0
{ c) n = -1
printf("*****\n"); d) None of the above
n = n + 1;
}
printf("n = %d", n);
11 - What does the code print to the
screen? a) 3
b) 8
int n = 3, x = 10; c) -1
while(n != 3 || x > 5) d) None of the above
{
n = n + 5;
if ( n > 7 )
{
printf ("%d\n", n);
break;
}
}
12 - What does the code print to the
screen?
int n = 3; a) 3
while( n > 1) b) 0
{ c) 8
n = n + 5; d) None of the above
if ( n <= 7 )
{
break;
printf ("%d\n", n);
}
printf ("%d\n", n);
13 - What does the code print to the
screen?
a) One Two Three
int i = 2; b) Two Three Four
c) One Two Four
printf("One "); d) One Three Four
if(i>1) e) None of the above
printf("Two ");
else
printf("Three ");
printf("Four ");
14 - what does the code print to the
screen ?
char option = 'h'; a) Hello
b) Take care
switch(option) c) Bye
{ d) None of the above
case 'H' : printf("Hello");
break;
case 'W' : printf("Welcome");
break;
case 'B' : printf("Bye");
break;
default: printf("Take care");
}
15 -what does the code print to the
screen ? a) Outside Loop
int counter = 2; b) Inside Loop
c) Inside LoopOutside Loop
while (counter < 10) d) None of the above
{
counter ++;
if ( counter < 5 ) continue;
else if ( counter >=6 ) break;
printf("Inside Loop");
}
printf("Outside Loop");