Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /* FUNCTIONS
- returned_type name([arguments])
- {
- body_of_the_function
- }
- */
- // a function which doesn't return any value and doesn't capture any arguments:
- void function1()
- {
- cout << "The function has been called\n";
- }
- // a function which doesn't return any value but it takes two arguments
- void sum(int a, int b)
- {
- cout << a << " + " << b << " = " << a + b << endl;
- }
- // a function which returns the result (double) and takes two arguments
- double divide(int a, int b)
- {
- return 1.0 * a / b;
- }
- int main()
- {
- function1();
- sum(17, 18);
- sum(5, 10);
- sum(3, 12);
- int x = 100, y = 20;
- sum(x, y);
- double result = divide(x, y);
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment