Home » C++ Programming » Introduction » Question
  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. 2
    2. 3
    3. 4
    4. 5
    5. Compilation Error
Correct Option: A

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



Your comments will be displayed only after manual approval.