Thursday, October 28, 2010

Area Of Geometry Shape

#include

#include

class geometry

{

float area,perimeter,l,b,r,h;

public:

void area_rec()

{

cout<<"\n enter the length and breath\n";

cin>>l>>b;

area=l*b;

cout<<"\n area is:"<

}

void area_circle()

{

cout<<"\n enter the radius:";

cin>>r;

area=3.14*r*r;

cout<<"\n area is:"<

}

void area_tri()

{

cout<<"\n enter the base and heigth\n ";

cin>>b>>h;

area=0.5*b*h;

cout<<"\n area is:"<

}

};

void main()

{

clrscr();

geometry g;

int i;

cout<<"\n enter a choice";

cout<<"\n press 1 for area of rectangle ";

cout<<"\n press 2 for area of circle";

cout<<"\n press 3 for area of triangle\n";

cin>>i;

switch(i)

{

case 1:g.area_rec();

break;

case 2:g.area_circle();

break;

case 3:g.area_tri();

break;

default:cout<<"\n wrong choice!!!";

}

getch();

}

OUTPUT

enter a choice

press 1 for area of rectangle

press 2 for area of circle

press 3 for area of triangle

1

enter the length and breath

5

4

area is:20

No comments:

Post a Comment