fork(1) download
  1. //@Author Damien Bell
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6.  
  7. //double productSet(double, double);
  8. void passByValue(double, double);
  9. void passByRef(double &, double &);
  10.  
  11.  
  12. int main(){
  13. double firstNumber=0, secondNumber=0, product=0;
  14. char quit =' ';
  15. while (quit != 'y'){
  16.  
  17. cout <<"Please enter your first number: ";
  18. cin >> firstNumber;
  19.  
  20. cout << "\nPlease enter your second number: ";
  21. cin >> secondNumber;
  22.  
  23.  
  24. // product=productSet(firstNumber,secondNumber);
  25.  
  26.  
  27. //cout << firstNumber<<endl;
  28. //cout << secondNumber<<endl;
  29. //cout << product<<endl;
  30.  
  31. passByValue(firstNumber, secondNumber);
  32. cout << firstNumber<<endl;
  33. cout << secondNumber<<endl;
  34. passByRef(firstNumber, secondNumber);
  35. cout << firstNumber<<endl;
  36. cout << secondNumber<<endl;
  37.  
  38.  
  39.  
  40.  
  41. cout <<"Do you want to quit? ";
  42. cin >> quit;
  43.  
  44.  
  45. }
  46.  
  47. return 0;
  48. }
  49.  
  50. //double productSet(double firstNumberProd, double secondNumberProd){
  51. //
  52. // firstNumberProd +=10;
  53. // secondNumberProd -=2;
  54. // double prodSet = firstNumberProd * secondNumberProd;
  55. // return prodSet;
  56. //}//end function
  57.  
  58.  
  59. void passByValue(double first, double second){
  60. first +=25;
  61. second +=50;
  62. }
  63.  
  64. void passByRef(double &first, double &second){
  65. first +=25;
  66. second +=50;
  67. }
  68.  
stdin
2
6
y
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13: warning: unused variable ‘product’
stdout
Please enter your first number: 
Please enter your second number: 2
6
27
56
Do you want to quit?