Suppose a b and c denote the lengths of the sides of a trian


Suppose a, b, and c denote the lengths of the sides of a triangle. Then the area of the triangle can be calculated using the formula: squareroot s(s-a) (s-b) (s-c) where s = (1/2) (a + b + c). Design an algorithm that uses this formula to find the area of a triangle. Implement your algorithm using either C++ or Java

Solution

Algorithm:

Step 1: INPUT a, b, c
Step 2 : s = (a + b + c) / 2
Step 3 : area = sqrt(s(s-a)(s-b)(s-c))
Step 4 : PRINT area

main.cpp

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
   float a,b,c,s,Area;
   cout<<\"Enter three sides of triangle : \";
   cin>>a>>b>>c;
   cout<<endl;
   s=(a+b+c)/2;
   Area=sqrt(s*(s-a)*(s-b)*(s-c));
   cout<<\"Area of triangle is : \"<<Area;
  
   return 0;
}

Output:-

 Suppose a, b, and c denote the lengths of the sides of a triangle. Then the area of the triangle can be calculated using the formula: squareroot s(s-a) (s-b) (

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site