Previous Next
0 / 20
Module DEMO-32-89DEMO-C-32

Hypotenuse Calculation

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program that calculates the length of the hypotenuse of a right-angled triangle given the other two sides a and b.

Use the formula: sqrt(a^2 + b^2).

Target difficulty: Easy

Constraints

a, b > 0

Input Format

Two floating-point numbers a and b.

Output Format

The hypotenuse length formatted to 2 decimal places.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
3.0 4.0
5.00
sqrt(3.0^2 + 4.0^2) = sqrt(9.0 + 16.0) = 5.00
Sample #2
Public sample
6.0 8.0
10.00
sqrt(6.0^2 + 8.0^2) = sqrt(36.0 + 64.0) = 10.00
Sample #3
Public sample
8.0 15.0
17.00
sqrt(8.0^2 + 15.0^2) = sqrt(64.0 + 225.0) = 17.00
Sample #4
Public sample
7.0 24.0
25.00
sqrt(7.0^2 + 24.0^2) = sqrt(49.0 + 576.0) = 25.00

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings