3.write A Menu Driven Program To Calculate Area of Circle and Square and Rectangle Using Function Overloading
The document describes a menu driven C++ program that uses function overloading to calculate the area of different shapes - circles, rectangles, and triangles. The program displays a menu asking the user to select which shape's area to calculate. Based on the selection, it prompts the user to input the appropriate parameters, calls the corresponding overloaded function which performs the calculation, and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
393 views2 pages
3.write A Menu Driven Program To Calculate Area of Circle and Square and Rectangle Using Function Overloading
The document describes a menu driven C++ program that uses function overloading to calculate the area of different shapes - circles, rectangles, and triangles. The program displays a menu asking the user to select which shape's area to calculate. Based on the selection, it prompts the user to input the appropriate parameters, calls the corresponding overloaded function which performs the calculation, and displays the result.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
3.
Write a menu driven program to calculate area of
circle and square And rectangle using function overloading. • #include <iostream.h> • #include <conio.h> • using namespace std; • class measure • { • public: • void shape(int r); • void shape(int l,int b); • void shape(float t,int d,int e); • }; • void measure::shape(int r) • { • cout<<"area of the circle is "<<3.14*r*r; • } • void measure::shape(int l,int b) • { • cout<<"area of the rectangle is"<<l*b; • } • void measure::shape(float t,int d,int e) • { • cout<<"area of the triangle is"<<t*d*e; • } • int main() • { • int r,d,e,l,b; • float t; • int ch; • measure obj; • cout<<"\tCALCULATION OF AREA AND VOLUME"; • cout<<"\n\n1. area of circle"; • cout<<"\n2. area of rectangle"; • cout<<"\n3. area of triangle"; • cout<<"\n\tEnter your choice "; • cin>>ch; • switch(ch) • { • case 1: • cout<<"enter the value of radius of the circle \n"; • cin>>r; • obj.shape(r); • break; • case 2: • cout<<"enter the sides of rectangle \n"; • cin>>l>>b; • obj.shape(l,b); • break; • case 3: • cout<<"enter the sides of triangle \n"; • cin>>d>>e; • obj.shape(0.5,d,e); • break; • default: • cout<<"\nThe choice entered is a wrong choice"; • } • getch (); • }