Program to tell the type of triangle based on its angles in C

Logic:

  • There are three types of triangle based on its angles
  • Right Angled Triangle: If any one angle is of 90.
  • Obtuse Angled Triangle: If any one angle is greater than 90.
  • Acute Angled Triangle: If all angles are less than 90.

Algorithm

  1. Enter three angles as a,b,c
  2. if(a==90 ||b==90||c==90)
  3. printf(“Triangle is right angle triangle\n”);
  4. else if (a>90 ||b>90 || c>90)
  5. printf(“Triangle is obtuse angle triangle\n”);
  6. else if(a<90 && b<90 && c<90)
  7. printf(” Triangle is acute angle triangle\n”);

Program

#include<stdio.h>
int main ()
{
printf("**********************************************************\n");
printf("**********************************************************\n");
printf("** WAP to tell the type of triangle based on its angles **\n");
printf("**           Created by Sheetal Garg                    **\n");
printf("**            Assistant Professor                       **\n");
printf("**            Phone No:9467863365                       **\n");
printf("**********************************************************\n");
printf("**********************************************************\n");
int a,b,c;
printf("Enter angles of triangle\n");
scanf("%d%d%d",&a,&b,&c);
if(a==90 ||b==90||c==90)
printf("Triangle is right angle triangle\n");
else if (a>90 ||b>90 || c>90)
printf("Triangle is obtuse angle triangle\n");
else if(a<90 && b<90 && c<90)
printf("Triangle is acute angle triangle\n");
return 0;
}

Output 1:

**********************************************************
**********************************************************
** WAP to tell the type of triangle based on its angles **
**           Created by Sheetal Garg                    **
**            Assistant Professor                       **
**            Phone No:9467863365                       **
**********************************************************
**********************************************************
Enter angles of triangle
90
80
10
Triangle is right angle triangle

Output 2:

**********************************************************
**********************************************************
** WAP to tell the type of triangle based on its angles **
**           Created by Sheetal Garg                    **
**            Assistant Professor                       **
**            Phone No:9467863365                       **
**********************************************************
**********************************************************
Enter angles of triangle
30
40
110
Triangle is obtuse angle triangle

Output 3:

**********************************************************
**********************************************************
** WAP to tell the type of triangle based on its angles **
**           Created by Sheetal Garg                    **
**            Assistant Professor                       **
**            Phone No:9467863365                       **
**********************************************************
**********************************************************
Enter angles of triangle
60
70
80
Triangle is acute angle triangle
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.