Subscribe For Free Updates!

We'll not spam mate! We promise.

Sunday 26 August 2012

C++ code to Displaying area of triangle, square and rectangle



// 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;
}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment