#include <stdio.h>
#include <math.h> // sqrt関数(平方根)を使うために必要

int main(void) {
    double side1, side2, hypotenuse;

    // 短辺2辺の入力を受け取る
    printf("1つ目の短辺の長さを入力してください: ");
    scanf("%lf", &side1);

    printf("2つ目の短辺の長さを入力してください: ");
    scanf("%lf", &side2);

    // 三平方の定理 (a^2 + b^2 = c^2) から長辺を計算
    hypotenuse = sqrt((side1 * side1) + (side2 * side2));

    // 結果を表示
    printf("長辺(斜辺)の長さは: %.2lf\n", hypotenuse);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: