Show List
Quiz - C - 2
Select the right answer for below questions:
What is the difference between the while loop and the for loop in C?
The while loop is used for a specific number of iterations, while the for loop is used for an indefinite number of iterations
The while loop is used for an indefinite number of iterations, while the for loop is used for a specific number of iterations
There is no difference between the while loop and the for loop
The while loop is used for an indefinite number of iterations, while the for loop is used for a specific number of iterations
What is the correct syntax for a do-while loop in C?
do { statements } while (condition);
do statements while (condition);
while (condition) { statements };
do { statements } while (condition);
What is the value of the following expression in C?
2 * 3 + 4
2 * 3 + 4
10
14
6
14
What is the output of the following code?
#include
int main() {
int x = 10;
if (x == 10)
printf("x is 10\n");
return 0;
}
#include
int main() {
int x = 10;
if (x == 10)
printf("x is 10\n");
return 0;
}
x is 10
x is not 10
Nothing is output
x is 10
What is the purpose of the continue statement in a loop?
To continue to the next iteration of the loop
To exit the loop immediately
To skip to the next iteration of the loop
To continue to the next iteration of the loop
What is the difference between single quotes and double quotes in C?
Single quotes are used to define a character constant, while double quotes are used to define a string constant
Double quotes are used to define a character constant, while single quotes are used to define a string constant
There is no difference between single quotes and double quotes
Single quotes are used to define a character constant, while double quotes are used to define a string constant
What is the output of the following code?
#include
int main() {
int x = 10;
if (x < 20) {
printf("x is less than 20\n");
} else {
printf("x is not less than 20\n");
}
return 0;
}
#include
int main() {
int x = 10;
if (x < 20) {
printf("x is less than 20\n");
} else {
printf("x is not less than 20\n");
}
return 0;
}
x is less than 20
x is not less than 20
Nothing is output
x is less than 20
What is the purpose of the break statement in a loop?
To break out of the loop and continue executing the code after the loop
To continue to the next iteration of the loop
To skip to the next iteration of the loop
To break out of the loop and continue executing the code after the loop
What is the value of the following expression in C?
5 / 2
5 / 2
2
2.5
3
3
What is the output of the following code?
#include
int main() {
int x = 0;
while (x < 10) {
printf("%d ", x);
x++;
}
return 0;
}
#include
int main() {
int x = 0;
while (x < 10) {
printf("%d ", x);
x++;
}
return 0;
}
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
Submit
Retry
{"qz1-455333":"The while loop is used for an indefinite number of iterations, while the for loop is used for a specific number of iterations","qz1-455334":"do { statements } while (condition);","qz1-455335":"14","qz1-455336":"x is 10","qz1-455337":"To continue to the next iteration of the loop","qz1-455338":"Single quotes are used to define a character constant, while double quotes are used to define a string constant","qz1-455339":"x is less than 20","qz1-455340":"To break out of the loop and continue executing the code after the loop","qz1-455341":"3","qz1-455342":"0 1 2 3 4 5 6 7 8 9"}
Leave a Comment