Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Problem Statement - Finding hypotenuse of a right angled triangle
Write a program to print hypotenuse of a right angled triangle if base and height of the triangle is given by the user.
Solution
TC++ #5328
Run Output
Give base and height of a right angle triangle : 4 5
Hypotenuse of given triangle = 6.40312
Notes
some student use the pow() function also to calculate squares of base and height also. They write above as -hyp = sqrt(pow(bs,2)+pow(ht,2)) ;This is okay but less efficient and sometime less precise also. pow() function is recommended for power of more than 3 and/or power in terms of fractions.