Program to enter 3 angles & check whether a triangle is possible or not in C

Logic:

A triangle is possible only if, sum of all three angles is 180

Algorithm

  1. Enter angles of triangle as a,b,c
  2. s = a+b+c;
  3. if(s==180)
  4. printf(“triangle is possible”);
  5. else
  6. printf(“triangle is not possible”);

Program

#include <stdio.h>
int main()
{
    printf("*************************************************************");
    printf("\n*************************************************************");
    printf("\n**  WAP to enter 3 angles & check if a triangle is possible**");
    printf("\n**                Created by Sheetal Garg                  **");
    printf("\n**                 Assistant Professor                     **");
    printf("\n**                 Phone No:9467863365                     **");
    printf("\n*************************************************************");
    printf("\n*************************************************************\n");
    int a, b, c, s;
    printf("enter the angles of a triangle\n");
    scanf("%d%d%d", &a, &b, &c);
    s = a + b + c;
    if (s == 180)
        printf("triangle is possible\n");
    else
        printf("triangle is not possible");
    return 0;
}

Output 1:

*************************************************************
*************************************************************
**  WAP to enter 3 angles & check if a triangle is possible**
**                Created by Sheetal Garg                  **
**                 Assistant Professor                     **
**                 Phone No:9467863365                     **
*************************************************************
*************************************************************
enter the angles of a triangle
60
30
90
triangle is possible

Output 2:

*************************************************************
*************************************************************
**  WAP to enter 3 angles & check if a triangle is possible**
**                Created by Sheetal Garg                  **
**                 Assistant Professor                     **
**                 Phone No:9467863365                     **
*************************************************************
*************************************************************
enter the angles of a triangle
60
30
80
triangle is not possible
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.