Program to check given angles form a triangle or not using if else

Program to check a triangle is formed or not

    The user will provide 3 angles to you. Your task is to check whether a triangle is formed or not. You need to add all the three provided angles and check if their sum is 180. If the sum is 180 print "It is a Triangle" otherwise print "It is not a Triangle". 


    

Code

#include <bits/stdc++.h>
using namespace std;


int main() {
    int a,b,c;
    cin>>a>>b>>c;
    
    int sum=a+b+c;
    
    if(sum==180){
        cout<<"It is a Triangle"<<endl;
    }
    else{
        cout<<"It is not a Triangle"<<endl;
    }
    
    return 0;
}


Input:
45 45 90

Output: 
It is a Triangle


Input:
90 45 90

Output: 
It is not a Triangle





!! SUBSCRIBE FOR MORE JOBES & CODES !!

Post a Comment

0 Comments