Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

198 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 141–150 of 198
Topics in C Programming
Q.141 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.142 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.143 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.144 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.145 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.146 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.147 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.148 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.149 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.150 Hard Control Flow
Consider the code:
int sum = 0;
for(int i = 1; i
A 25
B 55
C 30
D 45
Correct Answer:  A. 25
EXPLANATION

The loop adds only odd numbers (1,3,5,7,9) due to the continue statement when i is even. Sum = 1+3+5+7+9 = 25.

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