wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CS 50 CH 1 Review

Total questions: 56

Worksheet time: 39mins

Name
Class
Date
1.

Which of the following are correct variable declarations?

a)

int x;

b)

char bob;

c)

apples int;

d)

bool isEven;

2.

Which is the assignment operator?

a)

==

b)

>

c)

<

d)

&&

e)

=

3.

Which is the equality operator to check if the thing on the left equals the thing on the right?

a)

==

b)

>

c)

<

d)

&&

e)

=

4.

Which is the "greater than or equal to" operator?

a)

==

b)

>=

c)

>

d)

&&

e)

=

5.

Which is the logical AND operator?

a)

AND

b)

||

c)

OR

d)

&&

e)

&

6.

Which is the logical OR operator?

a)

AND

b)

||

c)

OR

d)

&&

e)

&

7.

What is the value of x after line 6?

a)

10

b)

8

c)

6

d)

12

8.

What is the value of x after line 5?

a)

10

b)

8

c)

6

d)

12

9.

What is the value of i the first time line 8 is executed?

a)

0

b)

2

c)

5

d)

10

10.

What is the value of x AFTER the first time line 8 is executed?

a)

0

b)

2

c)

8

d)

10

11.

What is the value of x AFTER the for-loop finishes?

a)

0

b)

2

c)

8

d)

10

12.

What is the value of i during the last loop execution?

a)

0

b)

2

c)

4

d)

5

13.

After the last loop runs, i++ happens again. Then i < 5 is evaluated. The answer to i < 5 at that point is:

a)

true

b)

false

c)

4

d)

5

14.

The logical statement i < 5 must be ___________ in order for the loop to run again.

a)

true

b)

false

c)

4

d)

5

15.

The order of execution in the very first loop of a for-loop is:

a)

Increment ( i++ ), conditional statement (i < 5), loop code (line 8)

b)

conditional statement (i < 5), loop code (line 8), Increment ( i++ )

c)

loop code (line 8), conditional statement (i < 5), Increment ( i++ )

d)

Increment ( i++ ), loop code (line 8), conditional statement (i < 5)

16.

Line 168 in the image is the first line of a function definition. What is the return type of this function?

a)

spot_is_taken

b)

int

c)

input

d)

bool

e)

void

17.

A parameter is the official name for the ____________ of a function?

a)

input

b)

output

c)

body

d)

return type

18.

Line 168 in the image is the first line of a function definition. What is the parameter type of this function?

a)

spot_is_taken

b)

int

c)

input

d)

bool

e)

void

19.

Line 168 in the image is the first line of a function definition. What is the name of the parameter of this function?

a)

spot_is_taken

b)

int

c)

input

d)

bool

e)

void

20.

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?

a)

bool spot_is_taken( void )

b)

char spot_is_taken( int input )

c)

void spot_is_taken( void )

d)

void spot_is_taken( int input)

e)

void

21.

What will be printed?

a)

10

b)

100

c)

%i

d)

y

e)

110

22.

What is the name of the custom function in this code?

a)

main()

b)

do_something()

c)

stdio.h

d)

printf()

e)

there is no custom function

23.

What is the return type of do_something() ?

a)

void

b)

float

c)

int

d)

bool

e)

char

24.

Inside the body of do_something(), if I want to use the number which is passed as an input, I should use which variable?

a)

x

b)

y

c)

void

d)

in

e)

10

25.

What does the \n on line 9 accomplish?

a)

Moves to the next line after printing the contents of y

b)

Nothing, you just have to put it because C is really dumb

c)

It moves to a new line before printing the contents of y

d)

Pelicans man... pelicans. They're so pretty.

26.

Which is the correct order of execution when tracing this code? (skipping blank lines and brackets)

a)

1, 3, 5, 7, 8, 9, 12, 14

b)

3, 1, 5, 7, 8, 12, 14, 9

c)

1, 3, 5, 7, 8, 12, 14, 9

d)

1, 3, 5, 7, 8, 12, 9, 14

27.

If grade is 65, what is letter?

a)

'A'

b)

'B'

c)

'C'

d)

'D'

e)

'F'

28.

If grade is 65, what is letter?

a)

'A'

b)

'B'

c)

'C'

d)

'D'

e)

'F'

29.

If grade is 90, what is letter?

a)

'A'

b)

'B'

c)

'C'

d)

'D'

e)

'F'

30.

If grade is 90, what is letter?

a)

'A'

b)

'B'

c)

'C'

d)

'D'

e)

'F'

31.

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?

a)

If-statements one after another

b)

If-else statements one after another

c)

Huh?

32.

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?

a)

If-statements one after another

b)

If-else statements one after another

c)

Huh?

33.

Which value of bob would cause "One" to be printed?

a)

2

b)

13

c)

16

d)

8

34.

What would be printed if bob = 4 ?

a)

"Two"

b)

"OneTwo"

c)

"One"

d)

nothing would print

35.

What would be printed if bob = 20 ?

a)

"Two"

b)

"OneTwo"

c)

"One"

d)

nothing would print

36.

What does bob % 2 do?

a)

It calculates bob divided by 2

b)

It calculates the remainder of bob divided by 2

c)

It finds 2 percent of bob

d)

It finds bob percent of 2

37.

What is the name of the % operator on line 10?

a)

remainder

b)

modulus (commonly called mod)

c)

percent

d)

Tiny circles separated by a slash

38.

A, B, C, and D are all bool type variables. A = true, B = false, C = true, D = true

A && ( B || ( C && D) ) = _______________

a)

true

b)

false

39.

A, B, C, and D are all bool type variables. A = false, B = true, C = true, D = true

A && ( B || ( C && D) ) = _______________

a)

true

b)

false

40.

A, B, C, and D are all bool type variables. A = true, B = true, C = false, D = true

A && ( B || ( C && D) ) = _______________

a)

true

b)

false

41.

We've used get_int() quite a bit. What kind of return type does it have?

a)

string

b)

int

c)

no return type

42.

We've used get_int() quite a bit. What kind of parameter type does it have?

a)

string

b)

int

c)

no return type

43.

Which data type would best store:

"Little Timmy jumped off a cliff"

a)

char

b)

bool

c)

int

d)

float

e)

string

44.

Which data type would best store:

'L'

a)

char

b)

bool

c)

int

d)

float

e)

string

45.

Which data type would best store:

42

a)

char

b)

bool

c)

int

d)

float

e)

string

46.

Which data type would best store:

3.1415

a)

char

b)

bool

c)

int

d)

float

e)

string

47.

printf() function belongs to the _____________ library.

a)

include

b)

stdio.h

c)

stdlib.h

d)

cs50.h

48.

round() function belongs to the ____________ library

a)

#include

b)

cs50.h

c)

math.h

d)

stdio.h

49.

get_string() function belongs to the _______________ library.

a)

#library

b)

stdio.h

c)

cs50.h

d)

stdlib.h

e)

ctype.h

50.

stdio.h library name stands for _________________.

a)

Standard Library

b)

Standard Input Output

c)

Standard Output Library

d)

printf()

51.

Which of the following are function calls?

a)

#include <stdio.h>

b)

printf("Hello world!");

c)

return (5+2);

d)

while (a<1) { };

52.

When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?

a)

Missing a ;

b)

Missing a }

c)

Missing a {

d)

Missing a "

e)

Missing a ,

53.

When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?

a)

Missing a ;

b)

Missing a }

c)

Missing a {

d)

Missing a "

e)

Missing a ,

54.

When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?

a)

Missing a ;

b)

Missing a }

c)

Missing a {

d)

Missing a "

e)

Missing a ,

55.

When I try to compile my code by using the make command in the Terminal, I get an error message. What's wrong?

a)

Missing a ;

b)

Missing a }

c)

Missing a {

d)

Missing a "

e)

Missing a ,

56.

When I try to compile this code by using the make command in the Terminal, I get an error message. What's wrong?

a)

Missing }

b)

Missing ;

c)

Bad placeholder

d)

Missing a library

e)

Variable not declared