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#include <iostream>
2using namespace std;
3
4// Create a function
5void myFunction() {
6 cout << "I just got executed!";
7}
8
9int main() {
10 myFunction(); // call the function
11 return 0;
12}
13
14// Outputs "I just got executed!"