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

Logic:

A triangle is possible only if, sum of any two sides is greater than third side.

Algorithm

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

Program

#include <stdio.h>
int main()
{
printf("*************************************************************");
printf("\n*************************************************************");
printf("\n**  WAP to enter 3 sides & 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 sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
s = a+b;
if(s>c)
printf("triangle is possible\n");
else
printf("triangle is not possible");
return 0;
}

Output 1:

*************************************************************
*************************************************************
**  WAP to enter 3 sides & check if a triangle is possible **
**                Created by Sheetal Garg                  **
**                 Assistant Professor                     **
**                 Phone No:9467863365                     **
*************************************************************
*************************************************************
enter sides of triangle
3    
4
5
triangle is possible

Output 2:

*************************************************************
*************************************************************
**  WAP to enter 3 sides & check if a triangle is possible **
**                Created by Sheetal Garg                  **
**                 Assistant Professor                     **
**                 Phone No:9467863365                     **
*************************************************************
*************************************************************
enter sides of triangle
3    
4
7
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.