Write a C Program to input two angles of a triangle 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.

Input first angle: 60

Input second angle: 80

Output third angle: 40

We know that sum of all angles of a triangle is 180° i.e. a + b + c = 180° (Where a,b,c are angles of triangles).

Happy coding ;)

**Example:**Input first angle: 60

Input second angle: 80

Output third angle: 40

### Required knowledge

Fundamentals of C, Data types, Talking user input in C, Properties of triangleWe know that sum of all angles of a triangle is 180° i.e. a + b + c = 180° (Where a,b,c are angles of triangles).

### Program

/** * C program to find all angles of a triangle if two angles are given */ #include <stdio.h> int main() { int a, b, c; //a, b, c are three angles of a triangle // Read two angles of the triangle from user printf("Enter two angles of triangle: "); scanf("%d %d", &a, &b); // Calculates the third angle c = 180 - (a + b); printf("Third angle of the triangle = %d", c); return 0; }

Output

Enter two angles of triangle : 60

30

Third angle of the triangle = 90

30

Third angle of the triangle = 90

Happy coding ;)

### You may also like

- 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 sum of two numbers.
- C program to find area of rectangle.
- C program to find diameter, circumference and area of circle.
- C program to convert length from centimeter to meter and kilometer.
- C program to convert temperature from Fahrenheit to Celsius.
- C program to convert days to years, weeks and days.
- C program to calculate Simple Interest.
- C program to calculate Compound Interest.

Basic C Program for Computer Programmer who want to learn. If you have simple wish you may visit. To get all update stay with us.

ReplyDeleteOutline:

• Language: C and Simscript.

• if (Condition) statement and Nested if statement is used to determine the given number is positive, negative, even or odd. Another way we solve this program using if-else-if ladder.

• When the given condition or expression is true the statement associated with it executed.

To know details:

http://www.secufoon.com/write-a-c-program-for-determining-a-number-is-positive-negative-even-or-odd/