1// function example
2#include <iostream>
3using namespace std;
4
5int addition (int a, int b)
6{
7 int r;
8 r=a+b;
9 return r;
10}
1#include <iostream>
2
3using namespace std;
4
5void function(){
6 cout << "I am a function!" << endl;
7}
8
9int main()
10{
11 function();
12
13 return 0;
14}
1#include <iostream>
2#include <stdlib.h>
3#include <iomanip>
4#include <fstream>
5using namespace std;
6
7void function_one(double, double, double);
8
9int main() {
10 double r1 = 1.0;
11 double r2 = 2.0;
12 double x = 0.0;
13 function_one(r1, r2, x);
14 return 0;
15}
16
17void function_one(double rmin, double rmax, double x0) {
18 cout << "Function got called" << endl;
19}
1// function returning the max between two numbers
2
3int max(int num1, int num2) {
4 // local variable declaration
5 int result;
6
7 if (num1 > num2)
8 result = num1;
9 else
10 result = num2;
11
12 return result;
13}
14
1// function example
2#include <iostream>
3using namespace std;
4
5int addition (int a, int b)
6{
7 int r;
8 r=a+b;
9 return r;
10}
11
12int main ()
13{
14 int z;
15 z = addition (5,3);
16 cout << "The result is " << z;
17}