Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // function example
- #include <iostream> //allows use of standard in / out steam (cout, cin, cerr)
- using namespace std; // allows cout, cin, cerr to be called directly without iostream.cin, etc
- //addition function is defined here, it is called explicitly later
- int addition (int a, int b)
- {
- int r;
- //r equals the passed in integer values
- r=a+b;
- //return the value of R where addition is called
- return (r);
- }
- //main function of the program
- //required to run
- //void shows we don't return anything from main, though int can be used to do so
- void main ()
- {
- //define variable types
- int i;
- int j;
- int z;
- //give starter values to i and j
- i = 1;
- j = 2;
- //call addition with I and J, Z will gain the return value
- z = addition (i,j);
- //cout will print the string to the screen
- cout << "The result is " << z;
- }
Add Comment
Please, Sign In to add comment