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 61–70 of 100
Topics in C Programming
Q.61 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.62 Medium Functions
Which of the following is a valid function pointer initialization?
A int (*fp)() = &printf;
B int (*fp)() = printf;
C int *fp = printf;
D Both A and B
Correct Answer:  D. Both A and B
EXPLANATION

Both forms are valid. Functions decay to function pointers, so both &printf and printf assign the function address correctly.

Take Test
Q.63 Hard Functions
How does the volatile keyword affect function behavior in C?
A It makes functions execute faster
B It prevents compiler optimization of variable accesses
C It changes function calling convention
D It has no effect on functions
Correct Answer:  B. It prevents compiler optimization of variable accesses
EXPLANATION

The volatile keyword tells the compiler not to optimize away variable accesses, ensuring the variable is read from memory each time.

Take Test
Q.64 Medium Functions
What will happen when this code executes?
void func() { func(); } int main() { func(); }
A Infinite recursion until stack overflow
B Compiler error
C Runtime error immediately
D Program exits gracefully
Correct Answer:  A. Infinite recursion until stack overflow
EXPLANATION

This is infinite recursion with no base case, causing stack overflow as the function keeps calling itself.

Take Test
Q.65 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.66 Hard Functions
What is the primary advantage of using function pointers in C?
A Faster execution than direct function calls
B Dynamic function selection at runtime
C Automatic memory management
D Better code readability
Correct Answer:  B. Dynamic function selection at runtime
EXPLANATION

Function pointers enable runtime polymorphism by allowing selection of which function to call based on runtime conditions.

Take Test
Q.67 Medium Functions
Which of the following about function declaration and definition is TRUE?
A Declaration and definition must be in the same file
B A function can be declared multiple times but defined only once
C Definition is optional if declaration is provided
D Declaration is optional in C
Correct Answer:  B. A function can be declared multiple times but defined only once
EXPLANATION

Functions can have multiple forward declarations but only one definition. This allows function prototypes in header files.

Take Test
Q.68 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.69 Hard Functions
In C99 and later standards, what is the maximum number of parameters a function can have?
A 255
B 256
C 127
D No fixed limit in standard, but implementation-dependent
Correct Answer:  D. No fixed limit in standard, but implementation-dependent
EXPLANATION

While C99 guarantees support for at least 127 parameters, the actual limit is implementation-dependent and varies by compiler.

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