C Exercises: Find the third angle of a triangle if two are given
C Input Output statement: Exercise-10 with Solution
Write a C program to find the third angle of a triangle if two angles are given.
Pictorial Presentation:
Sample Solution:
C Code:
#include <stdio.h>
int main()
{
int ang1, ang2, ang3; /*are three angles of a triangle */
/* Read two angles of the triangle from user separated by comma*/
printf("Input two angles of triangle separated by comma : ");
scanf("%d, %d", &ang1, &ang2);
ang3 = 180 - (ang1 + ang2); /* Calculates the third angle */
printf("Third angle of the triangle : %d\n", ang3);
return 0;
}
Sample Output:
Input two angles of triangle separated by comma : 50,70 Third angle of the triangle : 60
Flowchart:
C Programming Code Editor:
Previous: Write a C program to perform addition, subtraction, multiplication and division of two numbers.
Next: C Conditional Statement Exercises Home
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/c-programming-exercises/input-output/c-input-output-statement-exercises-10.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics