#include #include using namespace std; //First argument will represent the number of //arguments double average(int num,...) { va_list valist; double sum = 0.0; int i1 ; va_start(valist, num); //initialize valist for num number of arguments for (i1 = 0; i1 < num; i1++) { //access all the arguments assigned to valist sum += va_arg(valist, int); } va_end(valist); //clean memory reserved for valist return sum/num; } int main() { cout << "Average of 2, 3, 4, 5 = "<< average(4, 2,3,4,5) << endl; cout << "Average of 5, 10, 15 = "<< average(3, 5,10,15)<< endl; }