Show List
Quiz - C - 4
Select the right answer for below questions:
What is the output of the following code?
#include
int main() {
int x = 10;
while (x > 0) {
printf("%d ", x);
x--;
}
return 0;
}
#include
int main() {
int x = 10;
while (x > 0) {
printf("%d ", x);
x--;
}
return 0;
}
10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10
Nothing is output
10 9 8 7 6 5 4 3 2 1
What is the purpose of the "goto" statement in C programming?
To transfer control to a specified label within the program
To repeat a block of code
To terminate a program
To transfer control to a specified label within the program
What is the output of the following code?
#include
int main() {
int x = 10;
int y = 5;
if (x > y) {
printf("x is greater than y\n");
}
return 0;
}
#include
int main() {
int x = 10;
int y = 5;
if (x > y) {
printf("x is greater than y\n");
}
return 0;
}
x is greater than y
y is greater than x
Nothing is output
x is greater than y
What is the difference between a for loop and a while loop in C programming?
A for loop is used when the number of iterations is known, while a while loop is used when the number of iterations is unknown
A while loop is used when the number of iterations is known, while a for loop is used when the number of iterations is unknown
There is no difference between a for loop and a while loop
A for loop is used when the number of iterations is known, while a while loop is used when the number of iterations is unknown
What is the output of the following code?
#include
int main() {
int x = 10;
int y = 20;
int z = x + y;
printf("z = %d\n", z);
return 0;
}
#include
int main() {
int x = 10;
int y = 20;
int z = x + y;
printf("z = %d\n", z);
return 0;
}
z = 10
z = 20
z = 30
z = 30
What is the data type used to store decimal values in C programming?
int
char
float
float
What is the value of a variable with no value assigned to it called in C programming?
Null value
Undefined value
Null pointer
Undefined value
What is the function used to allocate memory dynamically in C programming?
malloc()
calloc()
realloc()
malloc()
What is the purpose of the break statement in C programming?
To exit a switch case
To continue with the next iteration of a loop
To return from a function
To exit a switch case
What is the difference between the '&' operator and the '*' operator in C programming?
'&' is used to get the address of a variable, while '*' is used to get the value stored at the address
*' is used to get the address of a variable, while '&' is used to get the value stored at the address
Both '&' and '*' are used to get the address of a variable
'&' is used to get the address of a variable, while '*' is used to get the value stored at the address
Submit
Retry
{"qz1-132048":"10 9 8 7 6 5 4 3 2 1","qz1-132049":"To transfer control to a specified label within the program","qz1-132050":"x is greater than y","qz1-132051":"A for loop is used when the number of iterations is known, while a while loop is used when the number of iterations is unknown","qz1-132052":"z = 30","qz1-132053":"float","qz1-132054":"Undefined value","qz1-132055":"malloc()","qz1-132056":"To exit a switch case","qz1-132057":"'&' is used to get the address of a variable, while '*' is used to get the value stored at the address"}
Leave a Comment