//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;
#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<<"
Area = "<<area;
cout<<endl;
return 0;
}
#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<<"
Area = "<<area;
cout<<endl;
return 0;
}
#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<<"
Area = "<<area;
cout<<endl;
return 0;
}
#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<<"
Area = "<<area;
cout<<endl;
return 0;
}
Code Example |
---|
Cpp :: how to change string to lowercase and uperCase in c++ |
Cpp :: print hello world on c++ |
Cpp :: C++ mutex lock/unlock |
Cpp :: what is __asm in C++ |
Cpp :: fabs() c++ |
Cpp :: cpp merge two sets |
Cpp :: tic toc toe c++ |
Cpp :: print in c++ |
Cpp :: c++ product of vector |
Cpp :: apply pca to dataframe |
Cpp :: taking a vector in c++ containing element |
Cpp :: check if float has decimals c++ |
Cpp :: string reversal |
Cpp :: c++ compare time |
Cpp :: c++ find element in vector |
Cpp :: array and for loop in c++ |
Cpp :: string to int in c++ |
Cpp :: max value of double c++ |
Cpp :: how print fload wiht 2 decimal in c++ |
Cpp :: c++ simple car game |
Cpp :: remove last index of the string in c++ |
Cpp :: c++ enum |
Cpp :: c++ greatest common divisor |
Cpp :: cpp cin |
Cpp :: Xor implementation C++ |
Cpp :: sort index c++ |
Cpp :: checking if a string has only letters cpp |
Cpp :: C++ Volume of a Cylinder |
Cpp :: stack implementation using class in c++ |
Cpp :: how to declare a 2D vector in c++ of size m*n with value 0 |