C-Variable Numbers and Arguments Questions and Answers

Practice Mode
Showing 10 of 28 questions
Q21
What is the main disadvantage of variable arguments?
  • A Slower performance
  • B Lack of type safety
  • C Limited to 10 arguments
  • D Cannot use with pointers
Answer: Option B
Explanation: Lack of type safety is the primary disadvantage as compiler cannot verify argument types.
Q22
Can variable argument functions be recursive?
  • A No, recursion is not allowed
  • B Yes, without restrictions
  • C Yes, but each call manages its own va_list
  • D Only if va_end is called before recursion
Answer: Option C
Explanation: Variable argument functions can be recursive, but each invocation manages its own argument list.
Q23
What happens if you call va_arg after va_end?
  • A It returns NULL
  • B It continues from where it left off
  • C It results in undefined behavior
  • D It restarts the argument list
Answer: Option C
Explanation: Calling va_arg after va_end results in undefined behavior.
Q24
Can you use variable arguments in main() function?
  • A No, main() cannot have variable arguments
  • B Yes, but it is not standard
  • C Only in Windows
  • D Yes, it is common practice
Answer: Option B
Explanation: The main function can have variable arguments, but standard signatures don't include them.
Q25
What is the role of the fixed parameter in variable argument functions?
  • A It is just a placeholder
  • B It provides info about variable arguments
  • C It must be zero
  • D It is ignored
Answer: Option B
Explanation: The fixed parameter often provides information about the variable arguments (count, types, or sentinel value).
Q26
Which of these is NOT a valid use of variable arguments?
  • A printf function
  • B Array declaration
  • C Custom logging function
  • D Sum function with variable numbers
Answer: Option B
Explanation: Variable arguments cannot be used for array declarations as they are a runtime feature.
Q27
What is variable argument in function prototype also known as?
  • A Optional arguments
  • B Default arguments
  • C Varargs
  • D Dynamic parameters
Answer: Option C
Explanation: The ellipsis (...) in function prototypes is called varargs, representing variable arguments.
Q28
Can variable argument functions have default arguments?
  • A Yes, they are the same thing
  • B No, C does not support default arguments
  • C Only in some compilers
  • D Yes, but only for the first parameter
Answer: Option B
Explanation: C does not support default arguments; this is a C++ feature. Variable arguments serve a different purpose.
Questions and Answers for Competitive Exams Various Entrance Test