Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C-Quiz-01

Total questions: 20

Worksheet time: 18mins

Name
Class
Date
1.

Explain what is #include <stdio.h> ?

4 lines
2.

What is printf for ?

a)

display some message in terminal.

b)

wait for user to reply

c)

exit the program

d)

draw a straight line

3.

what's the result of following code:
printf("Hello Students.\nI am from Nanyang\n");

a)

Hello Students. I am from Nanyang

b)

Hello Students.
I am from Nanyang

c)

Hello Students
I am from Nanyang

d)

Hello Students. I am from Medan

4.

Select which statement that is correct using scanf

a)

scanf("%d", number);

b)

scanf("%d", &number);

c)

scanf("%d %d", &number1, &number2);

d)

scanf("%d %d", number1, number2);

5.

In C, what is the difference between printf() and scanf() functions?

4 lines
6.

Which of the following is the correct way to read an integer in C?

a)

scanf("%d", num);

b)

scanf("%d", &num);

c)

scanf("%i", num);

d)

scanf(num, "%d");

7.

What is the output of the following code if x = 10?

a)

A

b)

B

c)

AB

d)

No output

8.

If the input given to the following code is 5 10, what will be the output?

a)

5

b)

10

c)

15

d)

510

9.

What happens if we write if (x = 0) instead of if (x == 0)?

a)

It will compare x with 0.

b)

It will cause a compilation error.

c)


It will assign 0 to x, then check the condition.

d)

It will always execute the else part.

10.

What is the output?

a)

Even

b)

7

c)

Odd

d)

No output

11.

What is printed if the input is 4?

a)

Big

b)

Small

c)

4

d)

No output

12.

What is the output?

a)

10

b)

20

c)

Equal

d)

No output

13.

What is the output if input is 6 2?

a)

Divisible

b)

Not Divisible

c)

6 2

d)

No output

14.

What will be printed?

a)

Zero

b)

Non-zero

c)

5

d)

No output

15.

What will be printed?

a)

Yes

b)

No

c)

Compilation error

d)

0

16.

What will be printed?

a)

P

b)

Q

c)

R

d)

No output

17.

What is the output if input is 3 7?

a)

3

b)

4

c)

Equal

d)

7

18.

If input is 7, what is printed?

a)

A

b)

B

c)

C

d)

D

19.

What will be printed?

a)

True

b)

False

c)

5

d)

Compilation error

20.

The program below is supposed to:

  1. Ask the user for a number.

  2. Divide the number by 2.

  3. Print the result.

But it contains syntax errors and a logic error.

Fix and write the correct one and also explain what's the error!

4 lines