forked from ksvkabra/learn-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewFun.cpp
More file actions
52 lines (44 loc) · 892 Bytes
/
newFun.cpp
File metadata and controls
52 lines (44 loc) · 892 Bytes
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
#include <iostream>
using namespace std;
void add(); // nn
void subtract(int x, int y); //yn
int multiply(); //ny
int divide(int, int); //yy
int factorial(int, int = 5); //function with default argument
int main()
{
int number = 10;
add();
subtract(10, 5);
int resultOfMultiply = multiply();
int resultOfDivide = divide(10, 2);
int factorialFun = factorial(1, 2);
int factorialWithOnlyOneParameter = factorial(1);
cout << resultOfDivide << endl
<< resultOfMultiply << endl
<< factorialFun << factorialWithOnlyOneParameter;
}
void add()
{
int x = 10, y = 20;
// cin >> x >> y;
cout << x + y;
}
void subtract(int x, int y)
{
cout << x - y;
}
int multiply()
{
int x = 10, y = 11;
// cin >> x >> y;
return x * y;
}
int divide(int x, int y)
{
return x / y;
}
int factorial(int x, int y)
{
return x * y;
}