Find the height of a right-angled triangle whose area is X times its base
Given that the area of a right-angled triangle is X times its base b. The task is to find the height of the given triangle.

Examples:
Input: X = 40
Output: 80
Input: X = 100
Output: 200
Approach: We know that the area of a right-angled triangle, Area = (base * height) / 2 and it is given that this area is X times the base i.e. base * X = (base * height) / 2.
Solving for height, we get height = (2 * base * X) / base = 2 * X.
Below is the implementation of the above approach:
C++
// C++ implementation of the approach #include <bits/stdc++.h> using namespace std; // Function to return the height of the // right-angled triangle whose area // is X times its base int getHeight(int X) { return (2 * X); } // Driver code int main() { int X = 35; cout << getHeight(X); return 0; } |
Java
// Java implementation of the approach import java.util.*; import java.lang.*; import java.io.*; class Gfg { // Function to return the height of the // right-angled triangle whose area // is X times its base static int getHeight(int X) { return (2 * X); } // Driver code public static void main (String[] args) throws java.lang.Exception { int X = 35; System.out.println(getHeight(X)) ; } } // This code is contributed by nidhiva |
Python3
# Python 3 implementation of the approach # Function to return the height of the # right-angled triangle whose area # is X times its base def getHeight(X): return (2 * X) # Driver code if __name__ == '__main__': X = 35 print(getHeight(X)) # This code is contributed by # Surendra_Gangwar |
C#
// C# implementation of the approach using System; class Gfg { // Function to return the height of the // right-angled triangle whose area // is X times its base static int getHeight(int X) { return (2 * X); } // Driver code public static void Main () { int X = 35; Console.WriteLine(getHeight(X)) ; } } // This code is contributed by anuj_67.. |
70
Recommended Posts:
- Minimum height of a triangle with given base and area
- Program to find area of a triangle
- Find the altitude and area of an isosceles triangle
- Find all sides of a right angled triangle from given hypotenuse and area | Set 1
- Find area of triangle if two vectors of two adjacent sides are given
- C++ program to find all numbers less than n, which are palindromic in base 10 and base 2.
- Given a number N in decimal base, find number of its digits in any base (base b)
- Maximum height when coins are arranged in a triangle
- Area of Reuleaux Triangle
- Check if right triangle possible from given area and hypotenuse
- Area of a triangle inside a parallelogram
- Area of Circumcircle of a Right Angled Triangle
- Area of Incircle of a Right Angled Triangle
- Area of the Largest Triangle inscribed in a Hexagon
- Area of largest triangle that can be inscribed within a rectangle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



