Find the third angle of a triangle
C program to find the third angle of a triangle if two angles are given.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int angle1, angle2, angle3;
printf("Enter two angles of triangle: ");
scanf("%d %d", &angle1, &angle2);
angle3 = 180 - (angle1 + angle2);
printf("\nThird angle of the triangle is: %d", angle3);
getch();
}
Output
Enter two angles of triangle: 30
40
Third angle of the triangle is: 110
Explanation
In this program, value of two angles is taken as an input from the user and stored in the variables named 'angle1' and 'angle2' respectively. As we all know, sum of all angles in a triangle is 180 degree.
i.e.
So, We have the values of two angles and third angle can be calculated using the formula
i.e.
angle1 + angle2 + angle3 = 180
So, We have the values of two angles and third angle can be calculated using the formula
angle3 = 180 - (angle1 + angle2)