xxxxxxxxxx
#include<iostream>
using namespace std;
int main()
{
float b, h, area;
cout<<"Enter Base length of Triangle: ";
cin>>b;
cout<<"Enter Height length of Triangle: ";
cin>>h;
area = 0.5*b*h;
cout<<"\nArea = "<<area;
cout<<endl;
return 0;
}
xxxxxxxxxx
//uisng Heron's Formula
float first, second, third, semiperimeter, area;
cout << "Input the first side of the triangle: ";
cin >> first;
cout << "Input the first side of the triangle: ";
cin >> second;
cout << "Input the third side of the triangle: ";
cin >> third;
semiperimeter = (first + second + third)/2;
area = sqrt (semiperimeter*(semiperimeter-first)*(semiperimeter-second)*(semiperimeter-third));
cout << "The area of the triangle is " << area << endl;
xxxxxxxxxx
#include<iostream>
using namespace std;
int main()
{
float b, h, area;
cout<<"Enter Base length of Triangle: ";
cin>>b;
cout<<"Enter Height length of Triangle: ";
cin>>h;
area = 0.5*b*h;
cout<<"\nArea = "<<area;
cout<<endl;
return 0;
}
xxxxxxxxxx
#include<iostream>
using namespace std;
int main()
{
float b, h, area;
cout<<"Enter Base length of Triangle: ";
cin>>b;
cout<<"Enter Height length of Triangle: ";
cin>>h;
area = 0.5*b*h;
cout<<"\nArea = "<<area;
cout<<endl;
return 0;
}
xxxxxxxxxx
#include<iostream>
using namespace std;
int main()
{
float b, h, area;
cout<<"Enter Base length of Triangle: ";
cin>>b;
cout<<"Enter Height length of Triangle: ";
cin>>h;
area = 0.5*b*h;
cout<<"\nArea = "<<area;
cout<<endl;
return 0;
}
xxxxxxxxxx
#include<iostream>
#include<math.h>
using namespace std;
int main(){
float side, area;
cout<<" Input the value of the side of the equilateral triangle: ";
cin>>side;
area = (sqrt(3) / 4) * (side * side);
cout<<" The area of equilateral triangle is: "<<area<<endl;
return 0;
}