Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +917541905230, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Monday, July 6, 2020

Program to find angles of a triangle if two angles are given

Program to find angles of a triangle if two angles are given:
By Ahmad Irshad | Programming Exercises and Solutions > find angles of a triangles in C

Write a C program to find third angle of a triangle if any two angles  are given by user. How to find and waht is the logic to find angles of a triangle is given below.

Properties of triangle:

Sum of angles of triangle | Protec
Remember: The sum of three interior angles of a triangle is 180°

For Example:
  1. a + b + c = 180
  2. a = 180 - (b + c) // To find angle a
  3. b = 180 - (a + c) // To find angle b
  4. c = 180 - (a + b) // To find angle c

Required knowledge for this exercise is

Before writing any program you just imagine about output screen first. For example, what input to be given, and output to be displayed. Let's have a look at the below example: 

INPUT:

Enter any angles of a triangle = 45, 60

OUTPUT:

Thirs angle of a triangle = 75


Logic to find any angle of a triangle:

Step by step logic to find any angle of a triangle.

1) Print a massage to the user like "Enter any two angle of triangle:" using printf();
2) Input any two angle of a triangle from user using scanf(); and store it in  variables a and b.
3) Now find thrid angle of a triangle using farmulla c = 180 - (a + b);
4) At last print the value of variable c. that's it!


Program to find angle of a triangle if two angles are given: 

  1. /* C program to find 3rd angle of a triangle if two angles are given */ #include <stdio.h> int main() { int a, b, c; /* Input two angles of a triangle */ printf("Enter any two angles of a triangle: "); scanf("%d%d", &a, &b); /* To find third angle since we know that
  2. * a + b + c = 180 therefore c = 180 - (a + b)
  3. */ c = 180 - (a + b); /* Print value of the third angle i.e c */ printf("Third angle of a triangle = %d", c); return 0; }

Output:

  1. Enter any two angles of a triangle = 45, 60
  2. Thirs angle of a trianlge  = 75



Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Help others by sharing this page.

Ahmad Irshad

Author & Editor

I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP

0 Comments:

Post a Comment

Please don't enter any spam link in the comment box.


Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec
Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec
Contact Us