Logic:
A triangle is possible only if, sum of all three angles is 180
Algorithm
- Enter angles of triangle as a,b,c
- s = a+b+c;
- if(s==180)
- printf(“triangle is possible”);
- else
- 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