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 51–60 of 100
Topics in C Programming
Q.51 Medium Functions
What does variadic function mean in C?
A A function with variable argument list using ... (ellipsis)
B A function that changes its return type
C A function that can be defined multiple times
D A function with optional parameters
Correct Answer:  A. A function with variable argument list using ... (ellipsis)
EXPLANATION

Variadic functions accept variable number of arguments using ellipsis (...) and accessed with va_list, va_arg macros.

Take Test
Q.52 Medium Functions
Consider: void modify(int *ptr) { *ptr = 20; } int main() { int x = 10; modify(&x); printf("%d", x); }. Output?
A 10
B 20
C Garbage value
D Compilation error
Correct Answer:  B. 20
EXPLANATION

This is call by reference using pointers. The function receives address of x, dereferences and modifies it to 20.

Take Test
Q.53 Medium Functions
What is the purpose of the 'extern' keyword when used with a function?
A To declare a function defined in another file
B To make function local to current file
C To increase function scope
D To optimize function performance
Correct Answer:  A. To declare a function defined in another file
EXPLANATION

extern allows you to declare a function defined elsewhere, enabling its use across multiple translation units.

Take Test
Q.54 Medium Functions
Which statement about function parameters passed as arrays is correct?
A Arrays are passed by value with a copy created
B Arrays decay to pointers and are passed by reference
C Array size is mandatory in function parameters
D Multidimensional arrays cannot be passed to functions
Correct Answer:  B. Arrays decay to pointers and are passed by reference
EXPLANATION

Arrays in C decay to pointers to their first element, effectively making them pass-by-reference. Changes inside function affect original array.

Take Test
Q.55 Medium Functions
What will be the output of this recursive function? int fact(int n) { if(n
A 5
B 25
C 120
D Infinite recursion error
Correct Answer:  C. 120
EXPLANATION

This calculates factorial. fact(5) = 5*4*3*2*1 = 120. Base case n<=1 stops recursion.

Take Test
Q.56 Medium Functions
Consider the code: int calculate(int a, int b = 5) { return a + b; }. What is the issue?
A Default parameters are allowed in C
B Default parameters are NOT allowed in C (only in C++)
C Syntax is incorrect
D Return type is missing
Correct Answer:  B. Default parameters are NOT allowed in C (only in C++)
EXPLANATION

Default parameters are a C++ feature, not available in standard C. C requires explicit arguments for all parameters.

Take Test
Q.57 Easy Functions
What is the main difference between function declaration and function definition?
A Declaration specifies name and parameters; definition provides implementation
B Declaration includes return type; definition doesn't
C They are exactly the same
D Definition must come before declaration
Correct Answer:  A. Declaration specifies name and parameters; definition provides implementation
EXPLANATION

Declaration (prototype) informs compiler about function signature; definition provides the actual implementation body.

Take Test
Q.58 Easy Functions
Which of the following is an example of call by value in C?
A void func(int *p) { *p = 10; }
B void func(int p) { p = 10; }
C void func(int &p) { p = 10; }
D void func(int arr[]) { arr[0] = 10; }
Correct Answer:  B. void func(int p) { p = 10; }
EXPLANATION

Call by value passes a copy of the variable. Changes inside the function don't affect the original variable. Option B demonstrates this principle.

Take Test
Q.59 Easy Functions
In C, what happens when a function is called before its declaration?
A It executes successfully with default int return type
B Compilation error occurs
C Runtime error occurs
D Function is automatically declared as extern
Correct Answer:  B. Compilation error occurs
EXPLANATION

C requires function declaration before use (forward declaration or definition). Calling without prior declaration causes compilation error in modern C standards.

Take Test
Q.60 Easy Functions
What is the return type of a function that performs an action but doesn't return any value?
A int
B void
C null
D empty
Correct Answer:  B. void
EXPLANATION

The void keyword is used as return type for functions that do not return any value.

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