fork download
  1.  
  2. #pragma warning(disable: 4996)
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #include <stdio.h>
  7. #include <cstdarg>
  8.  
  9. double product(int numArgs, ...);
  10.  
  11. int main(void)
  12. {
  13. double a = 1;
  14. double b = 2;
  15. double c = 3;
  16. double d = 4;
  17.  
  18. printf("The product is: %f", product(4, a, b, c, d));
  19.  
  20. printf("\n");
  21. return (0);
  22. }
  23.  
  24. double product(int numArgs, ... )
  25. {
  26. va_list ap;
  27. va_start(ap, numArgs);
  28.  
  29. double total = 0;
  30. for(int i = 0; i < numArgs; i++)
  31. {
  32. total += va_arg(ap, double);
  33. }
  34.  
  35. va_end(ap);
  36. return total;
  37. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
The product is: 10.000000