PROGRAM ON CALCULATING AREA OF CIRCLE,RECTANGLE AND TRIANGLE DEPENDING UPON USER CHOICE

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
   float area,rad,len,bre,a,b,c,s;
   int ch;
   clrscr();
   cout<<"Area Menu"<<"\n";
   cout<<"1.Circle"<<"\n";
   cout<<"2.Rectangle"<<"\n";
   cout<<"3.Triangle"<<"\n";
   cout<<"Enter your choice:";
   cin>>ch;
   cout<<"\n";
   switch(ch)
   {
      case 1: cout<<"Enter the radius of circle:";
     cin>>rad;
     area=3.14*rad*rad;
     cout<<"\n"<<"The area of circle is:"<<area<<"\n";
     break;
      case 2: cout<<"Enter the length and breadth of rectangle:";
     cin>>len>>bre;
     area=len*bre;
     cout<<"\n"<<"The area of rectangle is:"<<area<<"\n";
     break;
      case 3: cout<<"Enter three sides of triangle:";
     cin>>a>>b>>c;
     s=(a+b+c)/2;
     area=sqrt(s*(s-a)*(s-b)*(s-c));
     cout<<"\n"<<"The area of triangle is:"<<area<<"\n";
     break;
     default: cout<<"Wrong choice!!!!";
     break;
   }
   getch();
}

Comments

Popular Posts