fork download
  1. //@Author Damien Bell
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. double setVar(double);
  6. int outputVar(double, double);
  7.  
  8.  
  9. int main(){
  10. double firstNumber=0, secondNumber=0, firstPlusFive=0;
  11. char quit =' ';
  12. while (quit != 'y'){
  13.  
  14. cout <<"Please enter your first number: ";
  15. cin >> firstNumber;
  16.  
  17. cout << "\nPlease enter your second number: ";
  18. cin >> secondNumber;
  19.  
  20. firstPlusFive =setVar(firstNumber);
  21.  
  22. cout << "\n" << firstPlusFive <<endl<<endl;
  23.  
  24. cout << firstNumber << " + " << secondNumber << " = " << outputVar(firstNumber, secondNumber)<<endl;
  25.  
  26.  
  27.  
  28. cout <<"Do you want to quit? y/n: ";
  29. cin >> quit;
  30.  
  31.  
  32. }
  33.  
  34. return 0;
  35. }
  36.  
  37. double setVar(double firstValue){
  38. firstValue +=5;
  39. return firstValue;
  40. }
  41.  
  42. int outputVar (double first, double second){
  43. return (int(first+second));
  44. }
  45.  
  46. //Make 2 functions. Set a variable in int main() with 1 function
  47. //cout a returned variable in int main
  48.  
  49.  
Success #stdin #stdout 0s 2860KB
stdin
10
20
y
stdout
Please enter your first number: 
Please enter your second number: 
15

10 + 20 = 30
Do you want to quit? y/n: