Practice
Right-Angled Triangle Function
2024/May/June·Variant 1·Q6
MEDIUMProcedures & Functions
Adapted from Cambridge International AS & A Level Computer Science (9618), May/June 2024 Paper 21, Question 6.
Write function ISRA() that takes six integers representing the coordinates of three triangle vertices:
(x1, y1), (x2, y2), and (x3, y3).
The function must return TRUE if the triangle is right-angled and FALSE otherwise. Use squared lengths so no square root is needed:
A^2 = B^2 + C^2
Input: Six integers.
Output: TRUE or FALSE.
Example:
Input: 0
0
3
0
0
4
Output: TRUE
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: 3-4-5 triangle
Inputs: 0, 0, 3, 0, 0, 4
Expected: TRUE
Test 2: Not right-angled
Inputs: 0, 0, 2, 0, 1, 2
Expected: FALSE