// Displaying area of triangle, square and rectangle
// Programmer name: Sohail ahmed
// Date: 16/03/2010
#include<iostream.h>
#include<conio.h>
int main()
{
clrscr();
int option, heig, len, base;
cout<<"\nPress ( 1 ) for finding area of Square!"<<"\n\nPress ( 2 ) for finding area of Rectangle!"<<"\n\nPress ( 3 ) for finding area of Triangle\n\n";
cout<<"\nEnter your option: ";
cin>>option;
if(option==1)
{
cout<<"\nEnter height: ";
cin>>heig;
cout<<"\nEnter length: ";
cin>>len;
cout<<"\nArea of Square: "<<(len*len);
}
else if(option==2)
{
cout<<"\nEnter height: ";
cin>>heig;
cout<<"\nEnter base: ";
cin>>base;
cout<<"\nArea of ractangle: "<<(base*heig);
}
else if(option==3)
{
cout<<"\nEnter height: ";
cin>>heig;
cout<<"\nEnter base: ";
cin>>base;
cout<<"\nArea of triangle: "<<(0.5*heig*base);
}
else
{
cout<<"\nInvalid option!!";
}
getch();
return 0;
}
0 comments:
Post a Comment