Write a C program to enter two angles of a triangle and find the third angle - Basic C program



 


Write a C program to enter two angles of a triangle and find the third angle 


Objective :

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.


Example


Input
Enter first angle: 60
Enter second angle: 80
Output

Third angle = 40


Properties of triangle
Sum of angles of a triangle is 180°.

Logic to find third angle of a triangle

  1. Input two angles of triangle from user. Store it in some variable say a and b.
  2. Compute third angle of triangle using formula c = 180 - (a + b).
  3. Print value of third angle i.e. print c.


Solution:

/** * C program to find all angles of a triangle if two angles are given by CodexRitik */ #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; }



Note:

This Code is Verified by CodexRitik.If any error occurs then Comment correct code Below in comment box.

Disclaimer:-

The above hole problem solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.

Write a C program to enter two angles of a triangle and find the third angle - Basic C program Write a C program to enter two angles of a triangle and find the third angle - Basic C program Reviewed by CodexRitik on January 11, 2021 Rating: 5

2 comments:

Powered by Blogger.