C program to find the triangle is valid or not

VIGNESWARAN.S
2 min readJun 10, 2021

How can we check the Traingle is valid or not?

The triangle is valid when the sum of the three angles are equal to 180 °.If sum of the angles are not equal to 180 °,then the triangle is not valid.

Algorithm

  1. Input all three angles of triangle in some variable say angle1, angle2 and angle3.
  2. Find sum of all three angles, store sum in some variable say sum = angle1 + angle2 + angle3.
  3. Check if(sum == 180) then, triangle can be formed otherwise not.

Flowchart

Explanation

  1. Initially we usually gives #include<stdio.h>and #include<conio.h>

2.Second is main part.Inside the main part we are declaring the variables a1,a2,a3,s in the int data type.a1,a2,a3 are the variables denoting the angles. ‘s denotes the sum of the angles.

3.Then printing the the statement as “Enter a1,a2,a3”.Inside the scanf %d is used for the the int data type.

4.sum of the three angles is equal to 180 denotes the validity of triangle.

5.Then if else part.If sum of the triangle is equal to 180(s=180),print the statement “Triangle is Valid”

6.If sum of the triangle is not equal to 180,it will go to the else part.Then it will print the statement as “Triangle is Invalid”

Program or source code

Output

When we entering the values 60,60,60 for a1,a2,a3.The output is

When we entering the values 90,80,78 for a1,a2,a3.The output is

For any reference

--

--