- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find the hypotenuse of a right angled triangle with given two sides in C++

In this problem, we are given two integer values H and B defining height and base of a right angled triangle. Our task is to *find the hypotenuse of a right angled triangle with given two sides*.

Right Angled Triangle is a special triangle whose two angles are at right angles.

**Let's take an example to understand the problem,**

Input : B = 5, H = 12 Output : 13.00

## Solution Approach

A simple solution to the problem is using the concept of *pythagoras theorem* to find the hypotenuse of a triangle using the base and height.

**Pythagoras Theorem States** that the square of the hypotenuse of the right angled triangle is equal to the sum of squares of the other two sites of the triangle.

**Formulated as − **

$H^2\:=\:h^2\:+\:b^2$

## Example

Program to illustrate the working of our solution

#include <iostream> #include <math.h> using namespace std; double findHypotenuseTriangle(double h, double b) { return ( sqrt((h*h) + (b*b)) ); } int main() { double h = 5.0, b = 12.0; cout<<"Base of right angled triangle "<<b<<endl; cout<<"Height of right angled triangle "<<b<<endl; cout<<"Hypotenuse of right angled triangle = "<<findHypotenuseTriangle(h,b); return 0; }

## Output

Base of right angled triangle 12 Height of right angled triangle 12 Hypotenuse of right angled triangle = 13

- Related Articles
- Swift Program to find the hypotenuse of a right-angled triangle with sides l and b
- The two sides of a right-angled triangle are 6 cm and 8 cm. Find the length of the hypotenuse.
- In a right-angled triangle with sides $a$ and $b$ and hypotenuse $c$, the altitude drawn on the hypotenuse is $x$. Prove that $ab = cx$."
- The hypotenuse of a right angled triangle is ( 5 mathrm{~cm} ) and the other two sides differ by ( 1 mathrm{~cm} ). Find the other two sided of the triangle.
- Find x in the given Right angled triangle"
- In A Right Angled Triangle Base =12cm And Hypotenuse =15 CM Find The Perpendicular
- The hypotenuse of a right-angled triangle is 25 CM if one of the remaining two sides is 24 cm find the length of its third side.
- Check whether the given sides of a triangle form a right angled triangle.$a = 9, b = 12$ and $c = 16
- Find the Number of Possible Pairs of Hypotenuse and Area to Form Right Angled Triangle using C++
- Show that in a right angled triangle, the hypotenuse is the longest side.
- Find other two sides of a right angle triangle in C++
- The length of the hypotenuse of an isosceles right-angled triangle is 24. Find the area of the triangle.
- Find the dimensions of Right angled triangle in C++
- In a right - angled triangle, base is $12 cm$ and hypotenuse is $15 cm$. Find the Perpendicular.
- The length of the hypotenuse of an isosceles right-angled triangle is ( 20 . ) Find the perimeter and area of the triangle.

Advertisements