Tuesday, 4 October 2016

To find Area of different shapes using Menu options .

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();
int a;
float b,c,d,area;
cout<<setw(50)<<"..........MENU.........."<<"\n"<<"\n";
cout<<setw(60)<<"You can select options from the following "<<"\n"<<"\n"<<"\n";
cout<<setw(49)<<"1.To find area of a Square"<<"\n";
cout<<setw(53)<<"2.To find area of a Reactangle"<<"\n";
cout<<setw(49)<<"3.To find area of a Circle"<<"\n";
cout<<setw(56)<<"4.To find area of a Parallelogram"<<"\n";
cout<<setw(49)<<"5.To find area of Triangle"<<"\n";
cout<<setw(29)<<"6.Exit"<<"\n";
cin>>a;
switch (a)
{ case 1:
clrscr();
cout<<"You have chosen To find area of a Square"<<"\n";
cout<<"Enter side of the Square "<<"\n";
cin>>b;
area=b*b;
cout<<"Area of the Square ="<<area;
break;
  case 2:
clrscr();
cout<<"You have chosen To find area of a Rectangle"<<"\n";
cout<<"Enter length ";
cin>>b;
cout<<"Enter breadth ";
cin>>c;
area=b*c;
cout<<"Area of Rectangle = "<<area;
break;
  case 3:
clrscr();
cout<<"You have chosen To find area of a Circle "<<"\n";
cout<<"Enter Radius ";
cin>>b;
area=3.14*b*b;
cout<<"Area of the Circle = "<<area;
break;
  case 4:
clrscr();
cout<<"You have chosen To find Area of a Parallelogram "<<"\n";
cout<<"Enter Base ";
cin>>b;
cout<<"Enter Height ";
cin>>c;
area=b*c;
cout<<"Area of the Prallelogram = "<<area;
break;
  case 5:
clrscr();
cout<<"You have chosen To find area of a Triangle";
cout<<"Enter Height ";
cin>>b;
cout<<"Enter Base ";
cin>>c;
area=0.5*b*c;
cout<<"Area of Triangle = "<<area;
break;
  case 6:
clrscr();
textbackground(BLACK);
break;
  default:
 clrscr();
 textbackground(BLUE);
 textcolor(RED+BLINK);
 cout<<"Enter correct values ";
 break;
}
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...