Introduction


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    va_start


  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    void function(std::string message, ...);
    int main()
    {
    function("InterviewMania", 5, 7, 10, 8, 9);
    return 0;
    }
    void function(std::string message, ...)
    {
    va_list ptr;
    int number;
    va_start(ptr, message);
    number = va_arg(ptr, int);
    number = va_arg(ptr, int);
    cout << number;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, we are moving the pointer to the second value and printing it.



  1. Which header file should you include if you are to develop a function that can accept variable number of arguments?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    stdarg.h


  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    int funcion(char ch,...);
    int main()
    {
    int p, q;
    p = funcion('B', 2, 3, 4);
    q = funcion('3', 2.0, 2, '3', 2.0f, 10);
    cout << p<<" " << q;
    return 0;
    }
    int funcion(char ch,...)
    {
    return ch;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    In this program, we are returning the ascii value of the character and printing it.



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

    NA

    Correct Option: E

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