/* 3. Summative Assessment 2

Write a C++ program that calculate and displays the hypotenuse value

of right angle triangle. 

There are 2 right triangle base and height measurements:

The  first  triangle’s  base  is  3  and  height  is  5 .

The  second  triangle’s  base  is  4  and  height  of  8.

Find out the area of each triangle. Use a structure for this program.

The area of a triangle is computed as:

Area  =  0. 5  *  base  *  height

The output should be:

The  first  triangle  hypotenuse  is  5.83095

The  area  of  the  first  triangle  is  7 . 5

The  second  triangle  hypotenuse  is  8.94427

The  area  of  the  first  triangle  is  16

*/

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Program Listing

/* 3. Summative Assessment 2
Write a C++ program that calculate and displays the hypotenuse value
of right angle triangle.
There are 2 right triangle base and height measurements:
The  first  triangle's  base  is  3  and  height  is  5 .
The  second  triangle's  base  is  4  and  height  of  8.

Find out the area of each triangle. Use a structure for this program.
The area of a triangle is computed as:

Area  =  0. 5  *  base  *  height
The output should be:

The  first  triangle  hypotenuse  is  5.83095
The  area  of  the  first  triangle  is  7 . 5
The  second  triangle  hypotenuse  is  8.94427
The  area  of  the  first  triangle  is  16
*/

#include  <iostream>
#include  <string>
#include  <cmath>

using  namespace std;

struct  triangle
{
  float  a, b, c;
};

int  main()
{
  triangle t1 = { 3, 5 }, t2 = { 4, 8 };
  auto hypo1 = sqrt(t1.a * t1.a + t1.b * t1.b);
  cout << "The first triangle hypotenuse is " << hypo1 << "\n";

  auto area1 = 0.5f * t1.a * t1.b;
  cout << "The area of the first triangle is " << area1 << "\n";

  auto hypo2 = sqrt(t2.a * t2.a + t2.b * t2.b);
  cout << "The second triangle hypotenuse is " << hypo2 << "\n";

  auto area2 = 0.5f * t2.a * t2.b;
  cout << "The area of the second triangle is " << area2 << "\n";

  return  0;
}

Leave a Reply

Your email address will not be published.