PLAY WITH CODING

Home Basic Program If & Else Loops Conversion Pattern logo

Basic C Program

Program to find 3rdangle of a triangle if two angle are given

Input - Output

Input
Enter 1st angle of triangle : 68

Enter 2nd angle of triangle : 55

Output
3rd angle of triangle = 57

Algorithm

Step 1: START

Step 2: Enter first angle as input.

Step 3: Enter second angle as input.

Step 4: calculate 3rd angle i.e(180-1stangle-2ndangle).

Step 5: END

CODE


/* Find 3rd angle of triangle */

#include  <stdio.h>
int main()
{
      int first,second,third;
      printf("Enter the 1st angle in degree : ");
      scanf("%d",&first);
      printf("Enter the 2nd angle in degree : ");
      scanf("%d",&second);
      third=180-(first+second);
      printf("3rd angle of the triangle = %d",third);
    return 0;
}


/* Find 3rd angle of triangle */

#include  <iostream>
using namespace std;
int main()
{
      int first,second,third;
      cout<<"Enter the 1st angle in degree : ";
      cin>>first;
      cout<<"Enter the 2nd angle in degree : ";
      cin>>second;
      third=180-(first+second);
      cout<<"3rd angle of the triangle = "<<third;
    return 0;
}

OutPut

Enter 1st angle of triangle : 68
Enter 2nd angle of triangle : 55

3rd angle of triangle = 57