#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
void areaofcircle(void)
{
int radius;
cout<<" TO FIND THE AREA OF CIRCLE :"<<endl;
cout<<"\n\n\tEnter the radius of circle:"<<ends;
cin>> radius;
float area = 3.14*radius*radius;
cout<<"\n\n\t Area of circle: "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaoftriangle(void)
{
int base,height;
cout<<"\n\n TO FIND THE AREA OF TRIANGLE:"<<endl;
cout<<"\n\n\tEnter the base: ";
cin>>base;
cout<<"\n\n\tEnter the haight: ";
cin>>height;
float area=0.5*base*height;
cout<<"\n\n\tArea of triangle : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofequilateraltriangle(void)
{
int base;
cout<<"\n\n TO FIND THE AREA OF EQULATERAL TRIAGLE:"<<endl;
cout<<"\n\n\tLength of side is : ";
cin>>base;
float area=(float)(sqrt(3)*(base*base))/4;
cout<<"\n\n\tArea of Equilateral Triangle is : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofrectangle(void)
{
int base,height;
cout<<"\n\n TO FIND THE AREA OF RECTANGLE :"<<endl;
cout<<"\n\n\tEnter the length of rectangle :";
cin>>base;
cout<<"\n\n\tEnter the breadth of rectangle :";
cin>>height;
float area=base*height;
cout<<"\n\n\tArea of rectangle is :"<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofsquare(void)
{
int base;
cout<<"\n\n TO FIND THE AREA OF SQUARE :"<<endl;
cout<<"\n\n\tEnter the side of square :";
cin>>base;
float area=base*base;
cout<<"\n\n\tArea of square is :"<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofrhombus(void)
{
int base , height;
cout<<"\n\n TO FIND THE AREA OF RHOMBUS :"<<endl;
cout<<"\n\n\tEnter the values of diagonal :"<<ends;
cin>>base>>height;
float area=(base*height)/2;
cout<<"\n\n\tArea of rhombus is : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofpentagon(void)
{
int base;
cout<<"\n\n TO FIND THE AREA OF PENTAGON :"<<endl;
cout<<"\n\n\tEnter the length of side of pentagon :";
cin>>base;
float area=(sqrt(5*(5+2*sqrt(5))) * (base*base))/4;
cout<<"\n\n\tArea of Regular pentagon is : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofhexagon(void)
{
int base;
cout<<"\n\n TO FIND THE AREA OF HEXAGON :"<<endl;
cout<<"\n\n\tEnter the length of side of hexagon : ";
cin>>base;
float area=(3*sqrt(3)*base*base)/2;
cout<<"\n\n\tArea of Regular hexagon is : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofheptagon(void)
{
float apothem,perimeter,area;
int base;
cout<<"\n\n TO FIND THE AREA OF HEPTAGON :"<<endl;
cout<<"\n\n\tEnter the value of side of heptagon :";
cin>>base;
cout<<"\n\n\tEnter the value of apothem :";
cin>>apothem;
perimeter=7*base;
area=(perimeter*apothem)/2;
cout<<"\n\n\tArea of Regular heptagon : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaofoctagon(void)
{
int base;
cout<<"\n\n TO FIND THE AREA OF OCTAGON :"<<endl;
cout<<"\n\n\tEnter the length of side of octagon : ";
cin>>base;
float area=2*(1+sqrt(2))*base*base;
cout<<"\n\n\tArea of octagon is : "<<area;
getch();
cout<<"\n________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
}
void areaoftrapezoid(void)
{
int base,radius,height;
cout<<"\n\n TO FIND THE AREA OF TRAPEZOID :"<<endl;
cout<<"\n\n\tEnter the value of bases : "<<endl;
cin>>base>>radius;
cout<<"\n\n\tEnter the value of height : ";
cin>>height;
float area=(float)((base*radius)*height)/2;
cout<<"\n\n\tArea of Trapezoid is :"<<area;
getch();
cout<<"\n............................END............................................";
}
int main()
{
int a,i;
cout<<"________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
cout<<"\n\t\tEnter 1 for area of circle :"<<endl;
cout<<"\n\t\tEnter 2 for area of triangle :"<<endl;
cout<<"\n\t\tEnter 3 for area of equilateral triangle :"<<endl;
cout<<"\n\t\tEnter 4 for area of rectangle :"<<endl;
cout<<"\n\t\tEnter 5 for area of square :"<<endl;
cout<<"\n\t\tEnter 6 for area of rhombus :"<<endl;
cout<<"\n\t\tEnter 7 for area of pentagon :"<<endl;
cout<<"\n\t\tEnter 8 for area of hexagon :"<<endl;
cout<<"\n\t\tEnter 9 for area of heptagon :"<<endl;
cout<<"\n\t\tEnter 10 for area of octagon :"<<endl;
cout<<"\n\t\tEnter 11 for area of trapezoid :"<<endl;
cin>>i;
cout<<"________________________________________________________________________"<<endl;
cout<<"________________________________________________________________________"<<endl;
switch(i)
{
case 1:
areaofcircle();
break;
case 2:
areaoftriangle();
break;
case 3:
areaofequilateraltriangle();
break;
case 4:
areaofrectangle();
break;
case 5:
areaofsquare();
break;
case 6:
areaofrhombus();
break;
case 7:
areaofpentagon();
break;
case 8:
areaofhexagon();
break;
case 9:
areaofheptagon();
break;
case 10:
areaofoctagon();
break;
case 11:
areaoftrapezoid();
break;
default :
cout<<"Please Enter the valid key for areas:";
}
return 0;
}
No comments:
Post a Comment