WorksheetsQuiz d'Apprentissage C
Total questions: 15
Worksheet time: 8mins
What keyword is used to declare an integer variable in C?
int
float
char
double
What is the correct format to display an integer with printf?
%s
%d
%f
%c
Which library must be included to use printf and scanf?
#include
#include
#include
#include
What is the value of x after this code? int x = 5; x = x + 2 * 3;
11
21
16
10
What is the correct syntax to read an integer with scanf?
scanf("%d", &n);
scanf("%d", n);
scanf("%f", &n);
scanf(n, "%d");
Which operator is used to calculate the remainder of an integer division?
/
%
*
//
What is the size (in bytes) of an int on most modern compilers (32/64 bits)?
1
2
4
8
What will be the displayed result? printf("%d", 7 / 2);
3.5
3
4
Error
Which function is used to calculate the square root in C?
sqrt()
pow()
abs()
root()
Which library contains sqrt() and pow()?
#include
#include
#include
#include
What is the correct declaration for an array of 10 integers?
int tab[10];
int tab(10);
array tab[10];
tab int[10];
What will be the output? int a = 10, b = 3; printf("%d", a % b);
0
1
3
10
What is the role of return 0; in the main() function?
Indicate an error
Indicate that the program has terminated correctly
Display the value 0 on the screen
Reset the variables
What is the correct syntax for an if statement in C?
if x > 10 { ... }
if (x > 10) { ... }
if [x > 10] { ... }
if {x > 10} (...)
What is the output of the following code? int x = 5; printf("%d", ++x);
5
6
Error
Depends on the compiler
