Introduction


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Because the cstdarg defines this header file to process the unknown number of arguments.


  1. How can you access the arguments that are manipulated in the function?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    va_list



  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    float avg( int Count, ... )
    {
    va_list num;
    va_start(num, Count);
    int Sum = 0;
    for (int i = 0; i < Count; ++i )
    Sum += va_arg(num, int);
    va_end(num);
    return (Sum/Count);
    }
    int main()
    {
    float AVG = avg(5, 0, 1, 2, 3, 4);
    cout << "Average of first 5 whole numbers : " << AVG;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    We are just calculating the average of these numbers using cstdarg.


  1. What is the maximum number of arguments or parameters that can be present in one function call?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    256



  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. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

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