Font size
WorksheetsAP CS 50 CH 1 Review
Total questions: 56
Worksheet time: 39mins
Which of the following are correct variable declarations?
int x;
char bob;
apples int;
bool isEven;
Which is the assignment operator?
==
>
<
&&
=
Which is the equality operator to check if the thing on the left equals the thing on the right?
==
>
<
&&
=
Which is the "greater than or equal to" operator?
==
>=
>
&&
=
Which is the logical AND operator?
AND
||
OR
&&
&
Which is the logical OR operator?
AND
||
OR
&&
&
What is the value of x after line 6?
10
8
6
12
What is the value of x after line 5?
10
8
6
12
What is the value of i the first time line 8 is executed?
0
2
5
10
What is the value of x AFTER the first time line 8 is executed?
0
2
8
10
What is the value of x AFTER the for-loop finishes?
0
2
8
10
What is the value of i during the last loop execution?
0
2
4
5
After the last loop runs, i++ happens again. Then i < 5 is evaluated. The answer to i < 5 at that point is:
true
false
4
5
The logical statement i < 5 must be ___________ in order for the loop to run again.
true
false
4
5
The order of execution in the very first loop of a for-loop is:
Increment ( i++ ), conditional statement (i < 5), loop code (line 8)
conditional statement (i < 5), loop code (line 8), Increment ( i++ )
loop code (line 8), conditional statement (i < 5), Increment ( i++ )
Increment ( i++ ), loop code (line 8), conditional statement (i < 5)
Line 168 in the image is the first line of a function definition. What is the return type of this function?
spot_is_taken
int
input
bool
void
A parameter is the official name for the ____________ of a function?
input
output
body
return type
Line 168 in the image is the first line of a function definition. What is the parameter type of this function?
spot_is_taken
int
input
bool
void
Line 168 in the image is the first line of a function definition. What is the name of the parameter of this function?
spot_is_taken
int
input
bool
void
Line 168 in the image is the first line of a function definition. If I wanted to change this function to have no return statement, what would line 168 look like?
bool spot_is_taken( void )
char spot_is_taken( int input )
void spot_is_taken( void )
void spot_is_taken( int input)
void
What will be printed?
10
100
%i
y
110
What is the name of the custom function in this code?
main()
do_something()
stdio.h
printf()
there is no custom function
What is the return type of do_something() ?
void
float
int
bool
char
Inside the body of do_something(), if I want to use the number which is passed as an input, I should use which variable?
x
y
void
in
10
What does the \n on line 9 accomplish?
Moves to the next line after printing the contents of y
Nothing, you just have to put it because C is really dumb
It moves to a new line before printing the contents of y
Pelicans man... pelicans. They're so pretty.
Which is the correct order of execution when tracing this code? (skipping blank lines and brackets)
1, 3, 5, 7, 8, 9, 12, 14
3, 1, 5, 7, 8, 12, 14, 9
1, 3, 5, 7, 8, 12, 14, 9
1, 3, 5, 7, 8, 12, 9, 14
If grade is 65, what is letter?
'A'
'B'
'C'
'D'
'F'
If grade is 65, what is letter?
'A'
'B'
'C'
'D'
'F'
If grade is 90, what is letter?
'A'
'B'
'C'
'D'
'F'
If grade is 90, what is letter?
'A'
'B'
'C'
'D'
'F'
When you need to do a bunch of logical tests, but you know only one of them will be true, what is the best way to connect the tests?
If-statements one after another
If-else statements one after another
Huh?
When you need to do a bunch of logical tests, and you know more than one could be true, what is the best way to connect the tests?
If-statements one after another
If-else statements one after another
Huh?
Which value of bob would cause "One" to be printed?
2
13
16
8
What would be printed if bob = 4 ?
"Two"
"OneTwo"
"One"
nothing would print
What would be printed if bob = 20 ?
"Two"
"OneTwo"
"One"
nothing would print
What does bob % 2 do?
It calculates bob divided by 2
It calculates the remainder of bob divided by 2
It finds 2 percent of bob
It finds bob percent of 2
What is the name of the % operator on line 10?
remainder
modulus (commonly called mod)
percent
Tiny circles separated by a slash
A, B, C, and D are all bool type variables. A = true, B = false, C = true, D = true
A && ( B || ( C && D) ) = _______________
true
false
A, B, C, and D are all bool type variables. A = false, B = true, C = true, D = true
A && ( B || ( C && D) ) = _______________
true
false
A, B, C, and D are all bool type variables. A = true, B = true, C = false, D = true
A && ( B || ( C && D) ) = _______________
true
false
We've used get_int() quite a bit. What kind of return type does it have?
string
int
no return type
We've used get_int() quite a bit. What kind of parameter type does it have?
string
int
no return type
Which data type would best store:
"Little Timmy jumped off a cliff"
char
bool
int
float
string
Which data type would best store:
'L'
char
bool
int
float
string
Which data type would best store:
42
char
bool
int
float
string
Which data type would best store:
3.1415
char
bool
int
float
string
printf() function belongs to the _____________ library.
include
stdio.h
stdlib.h
cs50.h
round() function belongs to the ____________ library
#include
cs50.h
math.h
stdio.h
get_string() function belongs to the _______________ library.
#library
stdio.h
cs50.h
stdlib.h
ctype.h
stdio.h library name stands for _________________.
Standard Library
Standard Input Output
Standard Output Library
printf()
Which of the following are function calls?
#include <stdio.h>
printf("Hello world!");
return (5+2);
while (a<1) { };
When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?
Missing a ;
Missing a }
Missing a {
Missing a "
Missing a ,
When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?
Missing a ;
Missing a }
Missing a {
Missing a "
Missing a ,
When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?
Missing a ;
Missing a }
Missing a {
Missing a "
Missing a ,
When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?
Missing a ;
Missing a }
Missing a {
Missing a "
Missing a ,
When I try to compile this code by using the make command in the Terminal, I get an error message. What's wrong?
Missing }
Missing ;
Bad placeholder
Missing a library
Variable not declared
