Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 191–200 of 291
Topics in C Programming
Q.191 Easy Functions
What is the output of: int add(int a, int b) { int result = a + b; return result; } If called as add(5, 3)?
A 8
B 5
C 3
D Undefined
Correct Answer:  A. 8
EXPLANATION

The function simply adds two integers and returns their sum, which is 5 + 3 = 8.

Test
Q.192 Easy Functions
Consider: int func(int x) { return ++x; } What is the difference if we use x++ instead of ++x?
A No difference in return value
B ++x returns x+1, x++ returns original x
C x++ is faster than ++x
D Depends on compiler optimization
Correct Answer:  B. ++x returns x+1, x++ returns original x
EXPLANATION

Pre-increment (++x) increments and returns the new value, while post-increment (x++) increments but returns the old value.

Test
Q.193 Easy Functions
Which keyword is used to create a function that can be expanded inline by the compiler without actual function call overhead?
A extern
B static
C inline
D register
Correct Answer:  C. inline
EXPLANATION

The 'inline' keyword (introduced in C99) suggests to the compiler to replace function calls with actual code, reducing call overhead.

Test
Q.194 Easy Functions
What is the scope of a function parameter in C?
A Global scope
B File scope
C Function scope
D Block scope
Correct Answer:  C. Function scope
EXPLANATION

Function parameters have function scope, meaning they are accessible throughout the entire function body.

Test
Q.195 Easy Functions
What is the return type of the strlen() function in C?
A int
B size_t
C char*
D void
Correct Answer:  B. size_t
EXPLANATION

strlen() returns size_t, which is an unsigned integer type used to represent sizes and counts in C.

Test
Q.196 Easy Functions
How many times can a function be called in a C program?
A Only once
B Maximum 10 times
C Unlimited times
D Maximum 100 times
Correct Answer:  C. Unlimited times
EXPLANATION

A function can be called as many times as needed within a program, limited only by memory and stack constraints.

Test
Q.197 Easy Functions
What will be the output of the following code?
int func(int x) { return x * 2; }
int main() { printf("%d", func(5)); }
A 5
B 10
C 20
D Error
Correct Answer:  B. 10
EXPLANATION

func(5) returns 5 * 2 = 10, which is then printed.

Test
Q.198 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);

Test
Q.199 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.

Test
Q.200 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.

Test
IGET
IGET AI
Online · Exam prep assistant
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