C++ LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART- B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

old

PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 . . .

write a c++ program to calculate area of triangle, rectangle and circle using function overloading

 
 #include < iostream .h >
#include < iomanip.h >
using namespace std;

class Area{
 
public :
float tri_area,base,height;
float circle_area,radius;
float rect_area;
float   width,lenght;
 
void findarea(float base,float hieght);//triangle
void findarea(float radius);//circle
void findarea( );// rectanle
    
};

// triangle
void  Area ::findarea(float base,float height){
tri_area=0.5*base*height;
}

//  
void  Area ::findarea(float radius ){
circle_area= 3.142 *radius*radius;
}
//  
void  Area ::findarea( ){

cout<<"enter  lenght : ";
cin>> lenght;
cout<< endl<< "enter  height : ";
cin>>height;

cout<< endl<< "enter  width : ";
cin >> width;
rect_area=  height *width*lenght;
}

 
int main(){

Area object1;

int ch;
cout<<"enter 1.triangle  2.circle 3. rectangle = ";
cin>>ch;

switch(ch){

case 1:
cout<<"enter  Base : ";
cin>>object1.base;
cout<< endl<<"enter  height : ";
cin >> object1.height;
 object1.findarea(object1.base,object1.height);

cout<< "area of triangle="<< object1.tri_area<< endl;

break;
case 2:

cout <<"enter  radius : ";
cin >> object1.radius;
 
 object1.findarea(object1.radius  );

cout<< "area of circle_area="<< object1.circle_area<< endl;

break;
case 3:

 object1.findarea();

cout<< "area of rect_area="<< object1.rect_area << endl;

break;
}
  
}