wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Programming Unit 2 Review

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the value of this expression using integer arithmetic:

7 / 4

a)

1

b)

2

c)

1.75

2.

What is the value of a in this code fragment

int a=3, b;

a)

0

b)

Nothing

c)

3

3.

Determine the value of this expression using integer arithmetic:

5 % 7

a)

0

b)

2

c)

5

4.

Determine the value of b in this code fragment:

int a=3, b;

b=++a;

a)

3

b)

4

c)

2

5.

Determine the value of the expression using integer arithmetic:

6 * 9 % 3 / 2

a)

2

b)

0

c)

18

6.

Determine the value of a in the second line of the code fragment:

int a=1, b=2;

a=b--;

a)

1

b)

0

c)

2

7.

Determine the value of b in the second line of the code fragment:

int a=1, b=2;

a=b--;

a)

1

b)

0

c)

2

8.

Which line of code is correct for the statement:

Add 1 variable to x.

a)

x++;

b)

x+1

c)

x+x

9.

Which line of code is incorrect for the statement:

Subtract 4 from the variable y.

a)

y-4

b)

y=y-4

c)

y-=4

10.

Which line of code is correct for the statement:

Read in a value for the integer variable num.

a)

printf("%d", &num);

b)

scanf("%d", num);

c)

scanf("%d", &num);

11.

What is the EXACT output from this code fragment:

float num=3.238;

printf("num=%.2f", num);

a)

Number=3.2

b)

num=3.238

c)

num=3.24

12.

What is the EXACT output from this code fragment:

int num=10;

if(num> 7 % 3 / 2 * 3)

printf("This is True");

else

printf("This is False");

a)

This is True

b)

This is False

13.

What symbol is used in conditional operators for AND:

a)

AND

b)

&&

c)

&

14.

What will be printed on the screen from this fragment:

int num=0;

printf("%d", ++num)

a)

0

b)

1

c)

2

15.

What is the abbreviated way to write this assignment statement:

total=total+num;

a)

t=t+n;

b)

total+=num

c)

total=(total+num)