Write a C Program to input two angles from user and find third angle of the triangle. How to find all angles of a triangle if two angles are given by user using C programming. C program to calculate the third angle of a triangle if two angles are given.
ExampleInput
Enter first angle: 60 Enter second angle: 80
Output
Third angle = 40
Required knowledge
Arithmetic operators, Data types, Basic input/output
Properties of triangle
Sum of angles of a triangle is 180°.

Let us apply basic math to derive formula for third angle. If two angles of a triangle are given, then third angle of triangle is given by –
![]()
Logic to find third angle of a triangle
Step by step descriptive logic to find third angle of a triangle –
- Input two angles of triangle from user. Store it in some variable say a and b.
- Compute third angle of triangle using formula
c = 180 - (a + b). - Print value of third angle i.e. print c.
Program to find angles of a triangle
/** * C program to find all angles of a triangle if two angles are given */ #include <stdio.h> int main() { int a, b, c; /* Input two angles of the triangle */ printf("Enter two angles of triangle: "); scanf("%d%d", &a, &b); /* Compute third angle */ c = 180 - (a + b); /* Print value of the third angle */ printf("Third angle of the triangle = %d", c); return 0; }Output
Enter two angles of triangle: 60 30 Third angle of the triangle = 90
Happy coding 😉
Recommended posts
- Basic C programming exercise index.
- C program to find area of triangle.
- C program to find area of equilateral triangle.
- C program to check whether a triangle is valid or not if all angles are given.
- C program to check whether a triangle is valid or not if all sides are given.
- C program to check whether a triangle is Equilateral, Scalene or Isosceles triangle.
- C program to find area of rectangle.