C Program to Find Third Angle of a Triangle

  • Write a C program find third angle of triangle.

Required Knowledge


We will first take two angles of a triangle as input from user using scanf function. To find the third angle of triangle we will use below mentioned angle sum property of a triangle.

Sum of all internal angles of a triangle is 180 degrees.
  • A + B + C = 180
Where A, B and C are the three internal angles of a triangle.

C program to find third angle of a triangle

/* 
 * Given two angles of a triangle, Here is the 
 * C program to find third angle
 */  
  
#include <stdio.h>  
#define ANGLE_SUM 180

int main() {
 /* Three angles of a triangle */
    float a1, a2, a3;  
  
    /* 
     * Take two angles as input from user 
     */  
    printf("Enter Two Angles of a Triangle\n");  
    scanf("%f %f", &a1, &a2);  
  
    /* Sum of all three angles of a triangle is 180 degrees */  
    a3 = ANGLE_SUM - (a1 + a2);  
  
    printf("Third Angle = %0.4f", a3);  
  
    return 0;  
}

Output
Enter Two Angles of a Triangle
30 60
Third Angle = 90.0000

Related Topics
C program to check whether three angles of triangle is valid or not
C program to check whether three sides of triangle is valid or not
C program to check whether a triangle is equilateral, isosceles or scalene.
C program to calculate area of a right angled triangle
C program to calculate area of an equilateral triangle
C Program to print Floyd's triangle
C program to print pascal triangle till N rows
C program to print triangle and pyramid patterns of star(*)
C program to calculate area of any triangle
List of all C programs