wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz d'Apprentissage C

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What keyword is used to declare an integer variable in C?

a)

int

b)

float

c)

char

d)

double

2.

What is the correct format to display an integer with printf?

a)

%s

b)

%d

c)

%f

d)

%c

3.

Which library must be included to use printf and scanf?

a)

#include

b)

#include

c)

#include

d)

#include

4.

What is the value of x after this code? int x = 5; x = x + 2 * 3;

a)

11

b)

21

c)

16

d)

10

5.

What is the correct syntax to read an integer with scanf?

a)

scanf("%d", &n);

b)

scanf("%d", n);

c)

scanf("%f", &n);

d)

scanf(n, "%d");

6.

Which operator is used to calculate the remainder of an integer division?

a)

/

b)

%

c)

*

d)

//

7.

What is the size (in bytes) of an int on most modern compilers (32/64 bits)?

a)

1

b)

2

c)

4

d)

8

8.

What will be the displayed result? printf("%d", 7 / 2);

a)

3.5

b)

3

c)

4

d)

Error

9.

Which function is used to calculate the square root in C?

a)

sqrt()

b)

pow()

c)

abs()

d)

root()

10.

Which library contains sqrt() and pow()?

a)

#include

b)

#include

c)

#include

d)

#include

11.

What is the correct declaration for an array of 10 integers?

a)

int tab[10];

b)

int tab(10);

c)

array tab[10];

d)

tab int[10];

12.

What will be the output? int a = 10, b = 3; printf("%d", a % b);

a)

0

b)

1

c)

3

d)

10

13.

What is the role of return 0; in the main() function?

a)

Indicate an error

b)

Indicate that the program has terminated correctly

c)

Display the value 0 on the screen

d)

Reset the variables

14.

What is the correct syntax for an if statement in C?

a)

if x > 10 { ... }

b)

if (x > 10) { ... }

c)

if [x > 10] { ... }

d)

if {x > 10} (...)

15.

What is the output of the following code? int x = 5; printf("%d", ++x);

a)

5

b)

6

c)

Error

d)

Depends on the compiler