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 191–200 of 303
Topics in C Programming
Q.191 Easy Functions
Which storage class specifier allows a function to be called only within the file where it is defined?
A static
B extern
C auto
D register
Correct Answer:  A. static
EXPLANATION

The static keyword restricts function scope to the file in which it is declared, preventing external linkage.

Take Test
Q.192 Easy Functions
In the context of recursion, which of the following is essential to avoid infinite recursion?
A Using static variables
B A base case that terminates recursion
C Declaring the function as inline
D Using pointers in function parameters
Correct Answer:  B. A base case that terminates recursion
EXPLANATION

A base case is essential in recursive functions to provide a termination condition, otherwise the function will recurse infinitely.

Take Test
Q.193 Easy Functions
What will be the output?
int func(int *p) { return *p; }
int main() { int x = 10; printf("%d", func(&x)); }
A 10
B Address of x
C Garbage value
D Compiler error
Correct Answer:  A. 10
EXPLANATION

The function receives a pointer to x, dereferences it with *p, and returns the value 10.

Take Test
Q.194 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.

Take Test
Q.195 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.

Take Test
Q.196 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.

Take Test
Q.197 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.

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

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

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

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