Unspecified Number of Arguments

1

What will initialize the list of arguments in stdarg.h header file?

A. va_list
B. va_start
C. va_arg
D. none of the mentioned

2

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

3

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.
    }
A. 6549
B. 4965
C. 6646
D. compile time error

4

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.
    }

A. 2436
B. 48697
C. 1111111
D. compile time error

5

What is the output of this program?

1.
    #include 
2.    
    #include 
3.    
    using namespace std;
4.    
    int add (int num, ...)
5.    
    {
6.    
        int sum = 0;
7.        
        va_list args;
8.        
        va_start (args,num);
9.        
        for (int i = 0; i < num; i++) {
10.        
            int num = va_arg (args,int);
11.            
            sum += num;
12.            
        }
13.        
        va_end (args);
14.        
        return sum;
15.        
    }
16.    
    int main (void)
17.    
    {
18.    
        int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7);
19.        
        cout << "The result is " << total;
20.        
        return 0;
21.        
    }
A. 32
B. 23
C. 48
D. compile time error