Home Subjects C Programming Functions

C Programming
Functions

C language from basics to advanced placement prep

28 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 21–28 of 28
Topics in C Programming
Q.21 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.22 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.23 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.24 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.25 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.26 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.27 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.28 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