• Language

    C

  • Description

    It reads three nonzero integers and determines and prints whether they are the sides of a right triangle.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int side_1, side_2, side_3;
    printf ("Enter the value of side 1: ");
    scanf ("%d", &side_1);
    (void) getchar ();
    printf ("Enter the value of side 2: ");
    scanf ("%d", &side_2);
    (void) getchar ();
    printf ("Enter the value of side 3: ");
    scanf ("%d", &side_3);
    (void) getchar ();
    if(side_1*side_1==side_2*side_2+side_3*side_3||side_2*side_2==side_3*side_3+side_1*side_1||side_3*side_3==side_1*side_1+side_2*side_2)
        printf ("They are the sides of a right triangle.\n");
    else
        printf ("They not are the sides of a right triangle.\n");
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}