Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1.The standard header _______ is used for variable list arguments (…) in C.
a) <stdio.h >
b) <stdlib.h>
c) <math.h>
d) <stdarg.h>

View Answer

Answer: d [Reason:] None.

2. va_end does whatever.
a) Cleanup is necessary
b) Must be called before the program returns
c) Cleanup is necessary & Must be called before the program returns
d) None of the mentioned

View Answer

Answer: c [Reason:] None.

3. 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("%cn", c);
  12.     }

a) Compile time error
b) Undefined behaviour
c) 97
d) a

View Answer

Answer: a [Reason:] None.

4. 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("%cn", c);
  15.     }

a) Compile time error
b) Undefined behaviour
c) 97
d) a

View Answer

Answer: a [Reason:] None.

5. 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("%cn", d);
  16.         va_end(li);
  17.     }

a) Compile time error
b) Undefined behaviour
c) a
d) b

View Answer

Answer: b [Reason:] None.

6. 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("%cn", d);
  16.         va_end(li);
  17.     }

a) Compile time error
b) Undefined behaviour
c) a
d) b

View Answer

Answer: d [Reason:] None.

7. 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("%fn", d);
  17.         va_end(li);
  18.     }

a) Compile time error
b) Undefined behaviour
c) 97.000000
d) 98.000000

View Answer

Answer: b [Reason:] None.