Program for Area calculation in C++

#include<iostream.h>
#include<conio.h>
class shape
{
float circle;
float rect;
public:
shape()
{
circle=0;
rect=0;
}
void area(float r)
{
circle=(3.14*r*r);
cout<<circle;
}
void area(float h, float l)
{
rect=h*l;
cout<<"\nThe area of rectangle is:"<<rect;
}
};
void main()
{
shape s1;
int ch;
float he,le,re;
clrscr();
cout<<"****************************************************\n";
do
{
cout<<"\nTo calculate area of rectangle press    1 : \nTo calculate area of circle press     2 : \nTo exit from program please press     3 :\n";
cout<<"\nPlease Enter Your Choice:";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter Hieght and length to calculate are of rectangle :\n";
cin>>he>>le;
s1.area(he,le);
break;
case 2:
cout<<"\nEnter radious to calculate are of circle :\n";
cin>>re;
s1.area(re);
break;
}
}
while(ch!=3);
cout<<"****************************************************\n";
}

Comments

Post a Comment

Popular posts from this blog

Program for calculating Simple Interest using the concept of Default Arguments

Program: Maximum number in three numbers in visual basic

Program for Checking whether the given number is Palindrome or not