-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.cpp
More file actions
66 lines (48 loc) · 1.2 KB
/
functions.cpp
File metadata and controls
66 lines (48 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
using namespace std;
// Create a function
void myFunction() {
cout << "myFunction in progress....\n";
}
void myFunction(string fname) {
cout << fname << " Refsnes\n";
}
void myFunction(string fname, int age){
cout << fname << " Refnes. " << age << " years old. \n";
}
int myFunction(int x) {
return 5 + x;
}
void swapNums(int &x, int &y) {
int z = x;
x = y;
y = z;
}
int plusFuncInt(int x, int y) {
return x + y;
}
double plusFuncDouble(double x, double y) {
return x + y;
}
int main() {
myFunction(); // call the function
myFunction("Will");
myFunction("Lee");
myFunction("Bowser");
myFunction("Bowser", 10);
cout << "\n" << myFunction(3) << "\n";
int firstNum = 10;
int secondNum = 20;
cout << "Before swap: " << "\n";
cout << firstNum << secondNum << "\n";
// Call the function, which will change the values of firstNum and secondNum
swapNums(firstNum, secondNum);
cout << "After swap: " << "\n";
cout << firstNum << secondNum << "\n";
int myNum1 = plusFuncInt(8, 5);
double myNum2 = plusFuncDouble(4.3, 6.26);
cout << "Int: " << myNum1 << "\n";
cout << "Double: " << myNum2;
return 0;
}
// Outputs "I just got executed!"