CPP

CPP

Unspecified Number of Arguments has 9 Questions

Which header file is used to pass unknown number of arguments to function?

stdlib.h
string.h
stdarg.h
none of the mentioned
How can you access the arguments that are manipulated in the function?

va_list
arg_list
both a & b
none of the mentioned
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     float avg( int Count, ... )
  5.     {
  6.         va_list Numbers;
  7.         va_start(Numbers, Count);
  8.         int Sum = 0;
  9.         for (int i = 0; i < Count; ++i )
  10.             Sum += va_arg(Numbers, int);
  11.         va_end(Numbers);
  12.         return (Sum/Count);
  13.     }
  14.     int main()
  15.     {
  16.         float Average = avg(10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  17.         cout << "Average of first 10 whole numbers : " << Average;
  18.         return 0;
  19.     }

4
5
6
7
What is the maximum number of arguments or parameters that can be present in one function call?

64
256
255
16
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     void dumplist(int, ...);
  5.     int main()
  6.     {
  7.         dumplist(2, 4, 8);
  8.         dumplist(3, 6, 9, 7);
  9.         return 0;
  10.     }
  11.     void dumplist(int n, ...)
  12.     {
  13.         va_list p;
  14.         int i;
  15.         va_start(p, n);
  16.         while (n-->0) {
  17.             i = va_arg(p, int);
  18.             cout << i;
  19.         }
  20.         va_end(p);
  21.     }

2436
48697
1111111
compile time error
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     int flue(char c,...);
  5.     int main()
  6.     {
  7.         int x, y;
  8.         x = flue('A', 1, 2, 3);
  9.         y = flue('1', 1.0,1, '1', 1.0f, 1l);
  10.         cout << x << y;
  11.         return 0;
  12.     }
  13.     int flue(char c,...)
  14.     {
  15.         return c;
  16.     }

6549
4965
6646
compile time error
Which header file should you include if you are to develop a function that can accept variable number of arguments?

a)varag.h
b)stdlib.h
c)stdio.h
d)stdarg.h
What is the output of this program?
  1.     #include 
  2.     #include 
  3.     using namespace std;
  4.     void fun(std::string msg, ...);
  5.     int main()
  6.     {
  7.         fun("AstiwzQUIZ", 1, 4, 7, 11, 0);
  8.         return 0;
  9.     }
  10.     void fun(std::string msg, ...)
  11.     {
  12.         va_list ptr;
  13.         int num;
  14.         va_start(ptr, msg);
  15.         num = va_arg(ptr, int);
  16.         num = va_arg(ptr, int);
  17.         cout << num;
  18.     }

6
5
8
4
What will initialize the list of arguments in stdarg.h header file?

va_list
va_start
va_arg
none of the mentioned