Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 201–210 of 303
Topics in C Programming
Q.201 Easy Functions
Which of the following is a correct function declaration?
A int add(int a, int b);
B add int(a, b);
C int add a, b;
D add(int a, int b) int;
Correct Answer:  A. int add(int a, int b);
EXPLANATION

Function declaration syntax is: return_type function_name(parameter_list);

Take Test
Q.202 Easy Functions
Which keyword is used to define a function in C?
A function
B def
C No keyword needed, just return type and name
D func
Correct Answer:  C. No keyword needed, just return type and name
EXPLANATION

In C, functions are defined by specifying the return type followed by the function name and parameters. No specific 'function' keyword is used.

Take Test
Q.203 Easy Functions
What is the primary purpose of using functions in C programming?
A To modularize code and improve reusability
B To increase memory consumption
C To slow down program execution
D To eliminate the need for loops
Correct Answer:  A. To modularize code and improve reusability
EXPLANATION

Functions allow code reusability, modularity, and easier maintenance. They break down complex problems into smaller, manageable pieces.

Take Test
Q.204 Easy Control Flow
Consider the following code snippet:
int x = 5;
do {
printf("%d ", x);
x--;
} while(x > 0);
What will be the output?
A 5 4 3 2 1
B 4 3 2 1
C 5 4 3 2 1 0
D No output
Correct Answer:  A. 5 4 3 2 1
EXPLANATION

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.

Take Test
Q.205 Easy Control Flow
What is the primary difference between 'break' and 'continue' statements in C loops?
A break exits the loop entirely, while continue skips the current iteration and proceeds to the next
B continue exits the loop entirely, while break skips the current iteration
C Both statements perform identical functions
D break skips iterations, continue terminates the program
Correct Answer:  A. break exits the loop entirely, while continue skips the current iteration and proceeds to the next
EXPLANATION

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.

Take Test
Q.206 Easy Control Flow
Which statement is true about the goto statement in modern C programming practices?
A It should be used for all control flow
B It is completely banned in C
C It is legal but generally avoided due to code clarity concerns
D It can only be used within switch statements
Correct Answer:  C. It is legal but generally avoided due to code clarity concerns
EXPLANATION

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.

Take Test
Q.207 Easy Control Flow
What is the purpose of the ternary operator (? :) in C?
A To replace multiple for loops
B To provide a shorthand for if-else statements
C To handle exceptions
D To declare three variables at once
Correct Answer:  B. To provide a shorthand for if-else statements
EXPLANATION

The ternary operator (condition ? true_value : false_value) is a concise alternative to if-else for simple conditional assignments.

Take Test
Q.208 Easy Control Flow
In which scenario would a do-while loop be preferred over a while loop?
A When the loop must execute at least once
B When the condition is checked before execution
C When nested loops are involved
D When break statement is used
Correct Answer:  A. When the loop must execute at least once
EXPLANATION

do-while executes the body first, then checks the condition, ensuring at least one execution.

Take Test
Q.209 Easy Control Flow
Which looping construct in C allows initialization, condition, and increment to be placed in a single line?
A while loop
B do-while loop
C for loop
D None of the above
Correct Answer:  C. for loop
EXPLANATION

The for loop syntax is for(init; condition; increment) allowing all three components in one statement.

Take Test
Q.210 Easy Control Flow
In a nested loop structure, which statement is used to skip the current iteration of the innermost loop only?
A break
B continue
C return
D exit()
Correct Answer:  B. continue
EXPLANATION

continue skips the current iteration of the innermost loop and moves to the next iteration, while break exits the loop entirely.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips