Home » C++ Programming » Introduction » Question
  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    int Addition(int number, ...)
    {
    int sum = 0;
    va_list args;
    va_start (args,number);
    for (int i = 0; i < number; i++)
    {
    int number = va_arg (args,int);
    sum += number;
    }
    va_end (args);
    return sum;
    }
    int main (void)
    {
    int Result = Addition(1, 10, 9, -1, 13, 23, -2, 9, 17);
    cout << "The result is " << Result;
    return 0;
    }
    1. 1
    2. 5
    3. 10
    4. 20
    5. Compilation Error
Correct Option: C

We are adding these numbers by using for statement and stdarg.



Your comments will be displayed only after manual approval.