fork(1) download
  1. //@Author Damien Bell
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. //void displayMenu();
  6. double prodSum(double, double);
  7.  
  8. int main(){
  9. int choice=0;
  10. double x=0, y=0, product=0;
  11. char quit =' ';
  12. while (quit != 'y'){
  13. cout <<"Enter a value for the first number: ";
  14. cin >> x;
  15.  
  16. cout <<"Enter a value for the second number: ";
  17. cin >> y;
  18.  
  19. product = prodSum(x,y);
  20.  
  21. cout << "The product of "<< x << " * " << y << " = "<< product<<endl;
  22.  
  23.  
  24. cout <<"Do you want to quit? y/n ";
  25. cin >>quit;
  26. }
  27. return 0;
  28. }
  29.  
  30. //void displayMenu(){
  31. // cout << "Press 1 to add" <<endl << "Press 2 to subtract" <<endl <<"Press 3 to multiply"<<endl;
  32. //}
  33.  
  34. double prodSum(double a, double b){
  35. cout << "The sum of " << a << " + " << b << " = " << a+b <<endl;
  36. double product=0;
  37. product = a*b;
  38. return product;//20
  39. }
  40.  
  41.  
  42.  
stdin
2
10
y
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:9: warning: unused variable ‘choice’
stdout
Enter a value for the first number: Enter a value for the second number: The sum of 2 + 10 = 12
The product of 2 * 10 = 20
Do you want to quit? y/n