fork download
  1. #include <iostream>
  2.  
  3. struct Pq_t
  4. {
  5. double product;
  6. double quotient;
  7. };
  8.  
  9. Pq_t f(double x, double y, Pq_t pq)
  10. {
  11. if(!y)
  12. {
  13. std::cout << "'Y' mustn't be a zero" << std::endl;
  14. exit(1);
  15. }
  16.  
  17. pq.product = x * y;
  18. pq.quotient = x / y;
  19. return pq;
  20. }
  21.  
  22. int main(int argc, char *argv[])
  23. {
  24.  
  25. Pq_t pq;
  26. pq = f(10, 2, pq);
  27.  
  28. std::cout << "answer is: product " << pq.product;
  29. std::cout << " quotient " << pq.quotient << std::endl;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
answer is: product 20 quotient 5