C Program to Find Third Angle of a Triangle

C Program to Find Third Angle of a Triangle

C program to find the third angle of a triangle; Through this tutorial, we will learn how to find the third angle of a triangle if two angles are given in c programs.

Programs and Algorithm to Find Third Angle of a Triangle

To find the third angle of a triangle if two angles are given in c programs:

  • Algorithm to find third angle of a triangle
  • C Program to Find Third Angle of a Triangle

Algorithm to find third angle of a triangle

Use the following algorithm to write a program to find the third angle of a triangle if two angles are given; as follows:

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

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 :- ");  
    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;  
}

The output of the above c program; as follows:

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

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *