1.The standard header _______ is used for variable list arguments (…) in C.
a) <stdio.h >
b) <stdlib.h>
c) <math.h>
d) <stdarg.h>
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
Answer
Answer: c [Reason:] None.
3. What is the output of this C code?
-
#include <stdio.h>
-
int f(char chr, ...);
-
int main()
-
{
-
char c = 97;
-
f(c);
-
return 0;
-
}
-
int f(char c, ...)
-
{
-
printf("%cn", c);
-
}
a) Compile time error
b) Undefined behaviour
c) 97
d) a
Answer
Answer: a [Reason:] None.
4. What is the output of this C code?
-
#include <stdio.h>
-
#include <stdarg.h>
-
int f(...);
-
int main()
-
{
-
char c = 97;
-
f(c);
-
return 0;
-
}
-
int f(...)
-
{
-
va_list li;
-
char c = va_arg(li, char);
-
printf("%cn", c);
-
}
a) Compile time error
b) Undefined behaviour
c) 97
d) a
Answer
Answer: a [Reason:] None.
5. What is the output of this C code?
-
#include <stdio.h>
-
#include <stdarg.h>
-
int f(char c, ...);
-
int main()
-
{
-
char c = 97, d = 98;
-
f(c, d);
-
return 0;
-
}
-
int f(char c, ...)
-
{
-
va_list li;
-
va_start(li, c);
-
char d = va_arg(li, char);
-
printf("%cn", d);
-
va_end(li);
-
}
a) Compile time error
b) Undefined behaviour
c) a
d) b
Answer
Answer: b [Reason:] None.
6. What is the output of this C code?
-
#include <stdio.h>
-
#include <stdarg.h>
-
int f(char c, ...);
-
int main()
-
{
-
char c = 97, d = 98;
-
f(c, d);
-
return 0;
-
}
-
int f(char c, ...)
-
{
-
va_list li;
-
va_start(li, c);
-
char d = va_arg(li, int);
-
printf("%cn", d);
-
va_end(li);
-
}
a) Compile time error
b) Undefined behaviour
c) a
d) b
Answer
Answer: d [Reason:] None.
7. What is the output of this C code?
-
#include <stdio.h>
-
#include <stdarg.h>
-
int f(int c, ...);
-
int main()
-
{
-
int c = 97;
-
float d = 98;
-
f(c, d);
-
return 0;
-
}
-
int f(int c, ...)
-
{
-
va_list li;
-
va_start(li, c);
-
float d = va_arg(li, float);
-
printf("%fn", d);
-
va_end(li);
-
}
a) Compile time error
b) Undefined behaviour
c) 97.000000
d) 98.000000
Answer
Answer: b [Reason:] None.