

#Right isosceles triangle sides code#
If we run the above code it will generate the following output − Maximum no. of square that can be accommodated : %d",numofSquares(base)) Return the calculation as the number of squares. The perimeter of an isosceles right triangle can be calculated with the help of the formula: P h + 2l, where 'h' is the length of the hypotenuse and 'l' is the length of the adjacent. The integer variable base is used to store the Base of triangle.įunction numofSquares(int b) is used to count the number of squares that triangle with base b can accommodate.Īt first b=b-2 −extra space from corner endsĪccording to formula, b=floor(b/2), this new b can have b*(b+1)/2 squares of side 2. The formula to calculate the perimeter of an isosceles triangle is P 2a + b where 'a' is the length of the two equal sides and 'b' is the base of the triangle.

Use formula of Ap = b*(b+1)/2….where new b=b-2Įxplanation base 12>2, squares 10/2=5, new base 12-2=10īase 10>2, squares 8/2=4, new base 10-2=8Įxplanation base 5>2, squares 3/2=1, new base 5-2=3īase 1>2 X Total squares=1 Approach used in the below program is as follows Same will be the case with height ( ag ). Let us know if you have any other suggestions Formulas and Calculations for an isosceles triangle: Sides of Isosceles Triangle: a c Angles of Isosceles. No we have to divide remaining base gd( or height ag) by 2 to count no. So first we will always need extra 2 units of length for these triangles. From the corner ends ‘a’ and ‘d’, triangles aib and cde would never contribute to any square. The given triangle of height ag and base gd has 3 squares of side 2 each. Refer to the below figure to understand the problem The sides base or height (both equal) are taken as input. The goal is to find the maximum number of squares that can fit into this right isosceles triangle of side 2 sq units. Right triangle is the one which has height(ag in fig.) and base (dg in fig.) perpendicular to each other. Isosceles triangle is the one which has two sides of equal length.
