C++: (6) : How to find the area of a triangle while base and hight of the triangle are given?
Code:
#include<iostream>
using namespace std;
int main(){
double b,h,a;
cout<<"*****Finding the area of a Triangle.*****"<<endl;
cout<<"Enter the base."<<endl;
cin>>b;
cout<<"Enter the height."<<endl;
cin>>h;
a= (b*h)/2;
cout<<"The area of triangle having base "<<b<<" and height "<<h<<" is: "<<a<<endl;
return 0;
}
OutPut:
*****Finding the area of a Triangle.*****
Enter the base.
5
Enter the height.
10
The area of triangle having base 5 and height 10 is: 25
No comments:
Post a Comment