Home » C++ Programming » Introduction » Question
  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    void List(int, ...);
    int main()
    {
    List(2, 5, 10);
    List(3, 6, 9, 7);
    return 0;
    }
    void List(int num, ...)
    {
    va_list a;
    int k;
    va_start(a, num);
    while (num-->0)
    {
    k = va_arg(a, int);
    cout << k;
    }
    va_end(a);
    }
    1. 2 5 10 3 6 9 7
    2. 2 3 5 6 7 9 10
    3. 10 9 7 6 5 3 2
    4. 5 6 7 9 3 2 10
    5. 5 10 6 9 7
Correct Option: E

In this program, we are eradicating the first value by comparing using while operator.



Your comments will be displayed only after manual approval.