Code Snippets C

#include
#include
double average(double j1 , double j2,...);
int main()
{
printf("\n Average = %lf", average(8.5, 4.5, 0.0));
printf("\n Average = %lf", average(3.0, 4.0));
printf("\n Average = %lf\n", average(0.0,1.8,3.5));
}
double average( double j1, double j2,...)
{
va_list parg;
double sum = j1+j2;
double value = 0;
int count = 2;
va_start(parg,j2);
while((value = va_arg(parg, double)) != 0.0)
{
sum += value;
printf("\n in averge = %.2lf", value);
count++;
}
va_end(parg); /* End variable argument process */
return sum/count;
}