An algorithm to check whether a triangle is valid or not, when the 3 angles of the triangle are given.

( Note: A triangle is valid if the sum of all the three angles is equal to 180 degrees.)

  1. Start
  2. Enter angles of triangle as an1, an2, an3.
  3. Check if (an1+an2+an3=180) then continue else GOTO step 6
  4. Print Triangle is valid
  5. GOTO Step 7
  6. 6. Print Triangle is invalid
  7. END

Flowchart to check whether a triangle is valid or not, when the 3 angles of the triangle are given.

Flowchart to check whether a triangle is valid or not, when the 3 angles of the triangle are given.
Flowchart to check whether a triangle is valid or not, when the 3 angles of the triangle are given.

C-Code to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees.

#include<stdio.h>
void main()
{
int an1,an2,an3,total;
printf("Enter First Angle of Triangle : ");
scanf("%d",&an1);
printf("Enter Second Angle of Triangle : ");
scanf("%d",&an2);
printf("Enter Third Angle of Triangle : ");
scanf("%d",&an3);
total=an1+an2+an3;
if(total==180)
     printf("The triangle is valid ");
else
      printf("The triangle is invalid");
}