Previous Next
0 / 13
Module DEMO-32-56DEMO-C-32

Triangle Validity Checker

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a C program to check whether a triangle can be formed with the given values for the angles.

A triangle is valid if and only if the sum of its three interior angles equals exactly 180 degrees and each angle is greater than 0.

For example, if the input angles are 40, 55, and 65, the sum is 160, which is not equal to 180, so the triangle is not valid.

Constraints

Each angle is an integer between -1000 and 1000 (inclusive) The program must read exactly three integers from standard input

Input Format

Input consists of a single line containing three integers representing the three angles of a triangle.

Output Format

Print exactly one line containing the message "The triangle is valid." if the triangle can be formed, or "The triangle is not valid." if it cannot be formed.

Sample Testcases

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

Sample #1
Public sample
40 55 65
The triangle is not valid.
Sum = 40 + 55 + 65 = 160 โ‰  180, so triangle is not valid
Sample #2
Public sample
60 60 60
The triangle is valid.
Sum = 60 + 60 + 60 = 180 and all angles > 0, so triangle is valid

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