Wednesday, November 9, 2011

Function overloading (c++)

#include<iostream.h>
#include<conio.h>
#define pi 3.1416
float area(float asu);       //Area of circle
float asu(float asu);    //Volume of cube
float volume(float asu,float asu1);  //Volume of cylender
float volume(float l,float asu,float h);   //volume of rectangle
int main()
{
clrscr();
cout<<"\n Area of circle="<<area(5);
cout<<"\n Volume of cube="<<asu(5);
cout<<"\n Volume of cylender="<<volume(5,5);
cout<<"\n Volume of rectangle="<<volume(5,5,5);
getch();
return 0;
}
float area(float r)      //Area of circle
{
return(pi*r*r);
}
float asu(float cube)
{
return(cube*cube*cube);
}
float volume(float r,float h)     //Volume of cylender
{
return(pi*r*r*h);
}
float volume(float l,float b,float h)     //Volume of rectungler
{
return (l*b*h);
}

From: Me

No comments:

Post a Comment

Comment of this content!