Which control flow statement allows jumping to a labeled location in C?
Answer: B
goto statement allows unconditional jump to a labeled location. Though generally discouraged, it's valid in C and sometimes used for error handling.
Q.82Easy
In the ternary operator expression (condition ? expr1 : expr2), if condition is true, which expression evaluates?
Answer: B
Ternary operator is short-circuit. If condition is true, expr1 evaluates and expr2 is skipped. If false, expr2 evaluates and expr1 is skipped.
Q.83Easy
Which statement is true about the goto statement in modern C programming?
Answer: B
goto is valid in C but discouraged in modern programming as it reduces code readability. However, it has legitimate uses in cleanup code and error handling.
Q.84Easy
In a for loop for(int i = 0; i < 5; i++), at what point does the increment happen?
Answer: B
For loop order: initialization → check condition → execute body → increment → repeat from condition check.
Q.85Easy
In a nested loop structure, which statement is used to skip the current iteration of the innermost loop only?
Answer: B
continue skips the current iteration of the innermost loop and moves to the next iteration, while break exits the loop entirely.
Advertisement
Q.86Easy
Which looping construct in C allows initialization, condition, and increment to be placed in a single line?
Answer: C
The for loop syntax is for(init; condition; increment) allowing all three components in one statement.
Q.87Easy
In which scenario would a do-while loop be preferred over a while loop?
Answer: A
do-while executes the body first, then checks the condition, ensuring at least one execution.
Q.88Easy
What is the purpose of the ternary operator (? :) in C?
Answer: B
The ternary operator (condition ? true_value : false_value) is a concise alternative to if-else for simple conditional assignments.
Q.89Easy
Which statement is true about the goto statement in modern C programming practices?
Answer: C
goto is legal in C but discouraged as it can create hard-to-follow code paths. It's acceptable in limited contexts like error handling.
Q.90Easy
What is the primary difference between 'break' and 'continue' statements in C loops?
Answer: A
break statement terminates the loop completely, whereas continue statement skips the remaining statements in the current iteration and moves to the next iteration of the loop.
Q.91Easy
Consider the following code snippet:
int x = 5;
do {
printf("%d ", x);
x--;
} while(x > 0);
What will be the output?
Answer: A
The do-while loop executes at least once. x starts at 5, prints 5, decrements to 4, and continues while x > 0. Loop executes for x = 5,4,3,2,1 and exits when x becomes 0.
Q.92Easy
What is the primary purpose of using functions in C programming?
Answer: A
Functions allow code reusability, modularity, and easier maintenance. They break down complex problems into smaller, manageable pieces.
Q.93Easy
Which keyword is used to define a function in C?
Answer: C
In C, functions are defined by specifying the return type followed by the function name and parameters. No specific 'function' keyword is used.
Q.94Easy
Which of the following is a correct function declaration?
Answer: A
Function declaration syntax is: return_type function_name(parameter_list);
Q.95Easy
What will be the output of the following code?
int func(int x) { return x * 2; }
int main() { printf("%d", func(5)); }
Answer: B
func(5) returns 5 * 2 = 10, which is then printed.
Q.96Easy
How many times can a function be called in a C program?
Answer: C
A function can be called as many times as needed within a program, limited only by memory and stack constraints.
Q.97Easy
What is the return type of the strlen() function in C?
Answer: B
strlen() returns size_t, which is an unsigned integer type used to represent sizes and counts in C.
Q.98Easy
What is the scope of a function parameter in C?
Answer: C
Function parameters have function scope, meaning they are accessible throughout the entire function body.
Q.99Easy
Which keyword is used to create a function that can be expanded inline by the compiler without actual function call overhead?
Answer: C
The 'inline' keyword (introduced in C99) suggests to the compiler to replace function calls with actual code, reducing call overhead.
Q.100Easy
Consider: int func(int x) { return ++x; } What is the difference if we use x++ instead of ++x?
Answer: B
Pre-increment (++x) increments and returns the new value, while post-increment (x++) increments but returns the old value.