>Write a program to find the area of cube, cylinder and rectangle using the concept of function overloading
>/* Write a program to find the area of cube, cylinder and rectangle using the concept of function overloading
Programmed by:
Name: Jitendra Kr Yadav
Roll: 10116 (NCIT-ELX)
Date: 12 july 2011 */
#include <iostream.h>
#include <conio.h>
inlineint area(int a)
{
return(6*a*a);
}
inline float area(float a, float b)
{
return(3.14*a*(a+b));
}
inlineint area(int a, int b)
{
return(a*b);
}
int main()
{
intlcu,lr,br;
floatrcy,hcy;
cout<<“Enter the length of cube: “;
cin>>lcu;
cout<<“Enter the radius and height of cylinder: “;
cin>>rcy>>hcy;
cout<<“Enter the length and breadth of rectangle: “;
cin>>lr>>br;
cout<<“The area of cube is: “<<area(lcu)<<endl<<“The area of cylinder is: “<<area(rcy,hcy)<<endl<<“The area of rectangle is: “<<area(lr,br);
getch();
}
Output Sample:
Enter the length of cube: 2
Enter the radius and height of cylinder: 3
4
Enter the length and breadth of rectangle: 5
6
The area of cube is : 24
The area of cylinder is 65.94
The area of rectangle is : 30
Comments (5)
[email protected]