-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19_Function_Overloading.cpp
More file actions
40 lines (31 loc) · 895 Bytes
/
19_Function_Overloading.cpp
File metadata and controls
40 lines (31 loc) · 895 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
#include<iostream>
using namespace std;
int sum(int a, int b){
cout << "Using function with 2 arguments: ";
return a+b;
}
int sum(int a, int b, int c){
cout << "Using function with 3 arguments: ";
return a+b+c;
}
// Calculate the volume of the cylinder
int volume(double r, int h){
return(3.14*r*r*h);
}
// Calculate the volume of the cube
int volume(int a){
return(a*a*a);
}
// Calculate the volume of the rectangle
int volume(int l, int b, int h){
return(l*b*h);
}
int main()
{
cout << "The sum of 3 and 6 is: "<< sum(3.67,6) <<endl;
cout << "The sum of 3, 7 and 6 is: "<< sum(3,7,6) <<endl<<endl;
cout << "The volume of cuboid of 3, 7 and 6 is: "<< volume(3,7,6) <<endl;
cout << "The volume of cube of side 3 is: "<< volume(3) <<endl;
cout << "The volume of cylinder of radius 3 and height 6 is: "<< volume(3,6) <<endl;
return 0;
}