Log In Register

Units


Variable Length Argument - Questions and Answers

 

Practice these Variable Length Argument under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Variable Length Argument for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Variable Length Argument of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Variable Length Argument.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Variable Length Argument under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Variable Length Argument topic of C Programming:

 

1.

Which of the following data-types are promoted when used as a parameter for an ellipsis?

Answer: Option B

Explanation:

2.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <stdarg.h>
  3.     int f(...);
  4.     int main()
  5.     {
  6.         char c = 97;
  7.         f(c);
  8.         return 0;
  9.     }
  10.     int f(...)
  11.     {
  12.         va_list li;
  13.         char c = va_arg(li, char);
  14.         printf("%c\n", c);
  15.     }

Answer: Option C

Explanation:

3.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <stdarg.h>
  3.     int f(char c, ...);
  4.     int main()
  5.     {
  6.         char c = 97, d = 98;
  7.         f(c, d);
  8.         return 0;
  9.     }
  10.     int f(char c, ...)
  11.     {
  12.         va_list li;
  13.         va_start(li, c);
  14.         char d = va_arg(li, char);
  15.         printf("%c\n", d);
  16.         va_end(li);
  17.     }

Answer: Option D

Explanation:

4.

The declaration … can

Answer: Option A

Explanation:

5.

The standard header _______ is used for variable list arguments (…) in C.

Answer: Option A

Explanation:

6.

Each call of va_arg

Answer: Option B

Explanation:

7.

Which of the following macro extracts an argument from the variable argument list (ie ellipsis)      and advance the pointer to the next argument?

Answer: Option D

Explanation:

8.

va_end does whatever.

Answer: Option B

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <stdarg.h>
  3.     void func(int, ...);
  4.     int main()
  5.     {
  6.         func(2, 3, 5, 7, 11, 13);
  7.         return 0;
  8.     }
  9.     void func(int n, ...)
  10.     {
  11.         int number, i = 0;
  12.         va_list start;
  13.         va_start(start, n);
  14.         while (i != 3)
  15.         {
  16.             number = va_arg(start, int);
  17.             i++;
  18.         }
  19.         printf("%d", number);
  20.     }

Answer: Option B

Explanation:

10.

Which header file includes a function for variable number of arguments?

Answer: Option C

Explanation:

11.

Which of the following function with ellipsis are illegal?

Answer: Option D

Explanation:

12.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <stdarg.h>
  3.     int f(char c, ...);
  4.     int main()
  5.     {
  6.         char c = 97, d = 98;
  7.         f(c, d);
  8.         return 0;
  9.     }
  10.     int f(char c, ...)
  11.     {
  12.         va_list li;
  13.         va_start(li, c);
  14.         char d = va_arg(li, int);
  15.         printf("%c\n", d);
  16.         va_end(li);
  17.     }

Answer: Option A

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int f(char chr, ...);
  3.     int main()
  4.     {
  5.         char c = 97;
  6.         f(c);
  7.         return 0;
  8.     }
  9.     int f(char c, ...)
  10.     {
  11.         printf("%c\n", c);
  12.     }

Answer: Option D

Explanation:

14.

The type va_list is used in an argument list

Answer: Option C

Explanation:

15.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <stdarg.h>
  3.     int f(int c, ...);
  4.     int main()
  5.     {
  6.         int c = 97;
  7.         float d = 98;
  8.         f(c, d);
  9.         return 0;
  10.     }
  11.     int f(int c, ...)
  12.     {
  13.         va_list li;
  14.         va_start(li, c);
  15.         float d = va_arg(li, float);
  16.         printf("%f\n", d);
  17.         va_end(li);
  18.     }

Answer: Option C

Explanation: