Program to find the third angle of a triangle if two angles are given.

Here, we have a basic program example to find the third angle of a triangle using different languages. This program is created in c language, c++, Java, and Python.

Program to find the third angle of a triangle in C language

#include <stdio.h>
int main()
{
    int angle1, angle2, angle3;

    printf("Enter first angle of the triangle: ");
    scanf("%d", &angle1);
    printf("Enter second angle of the triangle: ");
    scanf("%d", &angle2);
    angle3 = 180-(angle1 + angle2);
    printf("The third angle will be = %d ",angle3);

    return 0;
}

Program to find the third angle of a triangle in C++ language

#include<iostream>
using namespace std;
int main(){
int angle1, angle2, angle3;

    cout<<"Enter first angle of the triangle: ";
    cin>>angle1;
    cout<<"Enter second angle of the triangle: ";
    cin>>angle2;
    angle3 = 180-(angle1 + angle2);
    cout<<"The third angle will be: "<<angle3;

    return 0;
}

Program to find the third angle of a triangle in Python language

angle1 = int(input("Enter first angle of the triangle : "))
angle2 = int(input("Enter second angle of the triangle : "))
angle3 = 180 - (angle1 + angle2)
print("The third angle of the triangle will be: ", angle3)

Program to find the third angle of a triangle in Java language

import java.util.*;
class triangle
 {
   public static void main(String[] args)
    {
      int angle1, angle2, angle3;
  
      Scanner s=new Scanner(System.in);
      System.out.println("Enter first angle of the triangle :");
      angle1 = s.nextInt();
      System.out.println("Enter second angle of the triangle :");
      angle2 = s.nextInt();
      angle3 = 180 - (angle1 + angle2);
      System.out.println("The third angle of the triangle is : " +angle3);
}
}