148k views
0 votes
In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. If the triangle is a right triangle, output It is a right angled triangle If the triangle is not a right triangle, output It is not a right angled triangle.

User Nhowe
by
7.2k points

2 Answers

3 votes

Answer:

Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle.

x = int(input("Enter the first side: "))

y = int(input("Enter the second side: "))

z = int(input("Enter the third side: "))

if (x**2)==(y**2)+(z**2) or (y**2)==(x**2)+(z**2) or (z**2)==(x**2)+(y**2):

print("The triangle is a right triangle.")

else:

print("The triangle is not a right triangle.")

Step-by-step explanation:

Need to use the or statement to try the different combinations since the base and sides are not predetermined.

User Rkabhishek
by
6.4k points
6 votes

Answer:

// here is program in C.

// include header

#include <stdio.h>

#include<math.h>

//main function

int main()

Step-by-step explanation:

Read the sides of the triangle and assign them to x,y,z respectively.Then check ((x*x)==(y*y)+(z*z)||(y*y)==(x*x)+(z*z)||(z*z)==(y*y)+(x*x)).If it true then set flag=1.After this if flag==1 then print triangle is right angled else not right angled.

Output:

enter the length of all sides of triangle:3 4 5

right angled triangle.

User Paul Rubel
by
7.0k points