// This tut contains Function Overloading
#include<iostream>
using namespace std;
int add(int x, int y){
cout<<"The sum Using 2 argument add function is :"<<endl;
return x + y ;
}
int add(int x,int y,float z){
cout<<"The sum Using 3 argument add function is :"<<endl;
return x+y+z;
}
// Calculate the volume of a cylinder
int volume(double r, int h){
return(3.14 * r *r *h);
}
// Calculate the volume of a cube
int volume(int a){
return (a * a * a);
}
// Rectangular box
int volume (int l, int b, int h){
return (l*b*h);
}
int main(){
cout<<"The sum of 6 and 9 is "<<add(6,9)<<endl;
cout<<"The sum of 6, 9 and 12 is "<<add(6, 9, 12)<<endl;
cout<<"The volume of cuboid of 3, 6 and 9 is "<<volume(3, 6, 9)<<endl;
cout<<"The volume of cylinder of radius 5 and height 10 is "<<volume(5, 10)<<endl;
cout<<"The volume of cube of side 3 is "<<volume(3)<<endl;
return 0;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.