Write a C++ program to input the angles of a triangle and check whether the triangle is valid or not. You need to use the switch statement.
Flowchart to check that triangle is valid or not
C++ code to get the angles of a triangle and show that the triangle is valid or not
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#include<iostream> using namespace std; int main() { int a1,a2,a3,add; cout<<"enter angle1 of triangle "; cin>>a1; cout<<"enter angle2 of triangle"; cin>>a2; cout<<"enter angle3 of triangle"; cin>>a3; add=a1+a2+a3; switch (add) { case 180: cout<<"triangle is valid"; break; default: cout<<"triangle is not valid"; } return 0; } |
Output
enter angle1 of triangle 33
enter angle2 of triangle 44
enter angle3 of triangle 66
the triangle is not valid
SFT (Shamil’s Flow Table )
Are you interested to Read about SFT(Shamil’s Flow Table)?