-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut19.cpp
48 lines (37 loc) · 959 Bytes
/
tut19.cpp
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
#include <iostream>
using namespace std;
int sum(int a, int b)
{
cout << "using function with 2 arguments is " << endl;
return a + b;
}
int sum(int a, int b, int c)
{
cout << "using function with 3 arguments is " << endl;
return a + b + c;
}
// Calculates volume of cylinder
int volume(double r, int h)
{
return (3.14 * r * r * h);
}
// Caluculates volume of cube
int volume(int a)
{
return (a * a * a);
}
// Calculates volume of cuboid
int volume(int l, int b, int h)
{
return (l * b * h);
}
int main()
{
// Function Overloading
cout << "The sum of 3 and 6 " << sum(3, 6) << endl;
cout << "The sum of 3, 6 and 7 " << sum(3, 6, 7) << endl;
cout << "The volume of cuboid of dimensions 3, 6 and 7 is " << volume(3, 6, 7) << endl;
cout << "The volume of cylinder of radius 3 and height 7 is " << volume(3, 7) << endl;
cout << "The volume of cube of side 3 is " << volume(3) << endl;
return 0;
}