Sinux1

T8E3.cpp

Apr 19th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void average(float, float, float *);
  5.  
  6. int main()
  7. {
  8.     float input1, input2, outcome;
  9.  
  10.     cout << "Enter two numbers:  ";
  11.     cin >> input1 >> input2;
  12.  
  13.     average(input1, input2, &outcome);
  14.  
  15.     cout << "The average is : " << outcome;
  16.  
  17.  
  18.  
  19.     return 0;
  20. }
  21.  
  22. void average(float num1 , float num2 , float *result)
  23. {
  24.     // The star dereferences result ( The '*' is the dereferencing symbol)
  25.     *result = (num1 + num2) / 2.0;
  26. }
Add Comment
Please, Sign In to add comment