Guest User

Untitled

a guest
Jul 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. // function example
  2.  
  3. #include <iostream> //allows use of standard in / out steam (cout, cin, cerr)
  4. using namespace std; // allows cout, cin, cerr to be called directly without iostream.cin, etc
  5.  
  6.  
  7. //addition function is defined here, it is called explicitly later
  8. int addition (int a, int b)
  9. {
  10. int r;
  11. //r equals the passed in integer values
  12. r=a+b;
  13. //return the value of R where addition is called
  14. return (r);
  15. }
  16.  
  17.  
  18. //main function of the program
  19. //required to run
  20. //void shows we don't return anything from main, though int can be used to do so
  21. void main ()
  22. {
  23. //define variable types
  24. int i;
  25. int j;
  26. int z;
  27. //give starter values to i and j
  28. i = 1;
  29. j = 2;
  30. //call addition with I and J, Z will gain the return value
  31. z = addition (i,j);
  32. //cout will print the string to the screen
  33. cout << "The result is " << z;
  34. }
Add Comment
Please, Sign In to add comment