﻿ C exercises: Find the third angle of a triangle if two angles are given - w3resource

# 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.

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
```

C Programming Code Editor:

```#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;
}```

Improve this sample solution and post your code through Disqus.