-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10functions.cpp
More file actions
62 lines (46 loc) · 1.15 KB
/
Copy path10functions.cpp
File metadata and controls
62 lines (46 loc) · 1.15 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
#include<iostream>
#include<string>
#include<vector>
using namespace std;
void defaultfunction(int a = 10);
void modifystr(string &str);
void defaultfunction(int a){
cout << "This is a default function\n" << a << "\n";
}
void modifystr(string &str){
str += "World!";
}
void printarray(int mynums[5]){
for(int i = 0; i < 5; i++){
cout << mynums[i] << "\n";
}
}
int myfunc(int x, int y){ //function overloading
return x + y;
}
double myfunc(double x, double y){
return x + y;
}
int factorialrecursion(int n){
if(n == 1){
return 1;
}
else{
return n * factorialrecursion(n - 1);
}
}
int main()
{
defaultfunction();
defaultfunction(20);
string greetings = "Hello ";
cout << "Before modification: " << greetings << "\n";
modifystr(greetings);
cout << "After modification: " << greetings << "\n";
int mynums[5] = {1, 2, 3, 4, 5};
printarray(mynums);
cout << myfunc(10, 20) << "\n";
cout << myfunc(10.57, 20.5) << "\n";
cout << factorialrecursion(5) << "\n";
return 0;
}