Home Subjects C Programming Functions

C Programming
Functions

C language from basics to advanced placement prep

100 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 81–90 of 100
Topics in C Programming
Q.81 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.82 Hard Functions
What is function overloading in the context of C?
A C supports function overloading like C++
B C does not support function overloading; you must use different function names or variadic functions
C It means calling the same function multiple times
D It is a deprecated feature in modern C
Correct Answer:  B. C does not support function overloading; you must use different function names or variadic functions
EXPLANATION

C does not support function overloading. To achieve similar functionality, use different names or variadic functions (using ...) or union of function pointers.

Take Test
Q.83 Hard Functions
Which of the following is TRUE about inline functions in C99 standard?
A They are mandatory keywords
B They are hints to the compiler to expand function code inline
C They eliminate the need for function declarations
D They cannot have parameters
Correct Answer:  B. They are hints to the compiler to expand function code inline
EXPLANATION

The 'inline' keyword is a hint to the compiler to replace function calls with the function body, reducing overhead but increasing code size.

Take Test
Q.84 Hard Functions
What will be the output?
int counter() { static int count = 0; return ++count; }
int main() { printf("%d ", counter()); printf("%d ", counter()); printf("%d", counter()); }
A 0 0 0
B 1 2 3
C 1 1 1
D 3 3 3
Correct Answer:  B. 1 2 3
EXPLANATION

Static variable 'count' retains its value. First call: 0+1=1, second: 1+1=2, third: 2+1=3.

Take Test
Q.85 Hard Functions
What are static local variables in functions used for?
A To store values between function calls
B To make the function faster
C To reduce memory usage
D To prevent the function from being called
Correct Answer:  A. To store values between function calls
EXPLANATION

Static local variables retain their value between function calls, initialized only once, and are stored in data segment.

Take Test
Q.86 Hard Functions
What is the output of this code?
int* getPointer(int *p) { return p; }
int main() { int a = 10; int *ptr = getPointer(&a); printf("%d", *ptr); }
A 10
B Address of a
C Garbage value
D Error: Returning pointer to local variable
Correct Answer:  A. 10
EXPLANATION

The function receives the address of 'a', returns it, and dereferencing gives 10. However, returning pointers to local variables is risky in other contexts.

Take Test
Q.87 Hard Functions
How can you modify a variable inside a function and reflect the change in the calling function?
A Return the value
B Use pointers
C Use global variables
D All of the above
Correct Answer:  D. All of the above
EXPLANATION

All three methods work: return value, pass pointers, or use global variables. Each has different use cases and implications.

Take Test
Q.88 Medium Functions
What will be the output?
void modify(int x) { x = x + 10; }
int main() { int a = 5; modify(a); printf("%d", a); }
A 5
B 15
C 10
D Error
Correct Answer:  A. 5
EXPLANATION

Since parameters are passed by value, changes to 'x' inside modify() don't affect 'a' in main(). Output is 5.

Take Test
Q.89 Medium Functions
In C, are function parameters passed by value or by reference by default?
A By value
B By reference
C Depends on the data type
D Both simultaneously
Correct Answer:  A. By value
EXPLANATION

C passes parameters by value by default. To achieve pass-by-reference effect, pointers must be used explicitly.

Take Test
Q.90 Medium Functions
What is the issue with the following code?
int factorial(int n) { return n * factorial(n-1); }
A Syntax error
B No base case, leading to infinite recursion and stack overflow
C The function cannot call itself
D Missing return type
Correct Answer:  B. No base case, leading to infinite recursion and stack overflow
EXPLANATION

The recursive function lacks a base case (like if n==0 return 1) to terminate recursion, causing infinite recursion and stack overflow.

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