C-Variable Numbers and Arguments Questions and Answers
C Variable Numbers and Arguments questions with answers help developers understand how functions in C can accept a varying number of parameters. Using standard macros like va_start, va_arg, and va_end, C programmers can design flexible functions similar to printf(). These programming questions and answers guide learners through the core logic and syntax used in handling variable arguments effectively. Such concepts are often asked in programming interview questions with answers during technical rounds in companies like Infosys, Tech Mahindra, and Wipro. Practicing C programming MCQs related to variable arguments helps build confidence in function handling and efficient coding techniques.
C-Variable Numbers and Arguments
Showing 10 of
28 questions
21. What is the main disadvantage of variable arguments?
- Slower performance
- Lack of type safety
- Limited to 10 arguments
- Cannot use with pointers
22. Can variable argument functions be recursive?
- No, recursion is not allowed
- Yes, without restrictions
- Yes, but each call manages its own va_list
- Only if va_end is called before recursion
23. What happens if you call va_arg after va_end?
- It returns NULL
- It continues from where it left off
- It results in undefined behavior
- It restarts the argument list
24. Can you use variable arguments in main() function?
- No, main() cannot have variable arguments
- Yes, but it is not standard
- Only in Windows
- Yes, it is common practice
25. What is the role of the fixed parameter in variable argument functions?
- It is just a placeholder
- It provides info about variable arguments
- It must be zero
- It is ignored
26. Which of these is NOT a valid use of variable arguments?
- printf function
- Array declaration
- Custom logging function
- Sum function with variable numbers
27. What is variable argument in function prototype also known as?
- Optional arguments
- Default arguments
- Varargs
- Dynamic parameters
28. Can variable argument functions have default arguments?
- Yes, they are the same thing
- No, C does not support default arguments
- Only in some compilers
- Yes, but only for the first parameter