- 2

Write Programme In C++ for finding Right angle triangle using Pythagoras Theorem

25th Feb 2018, 7:17 AM
Obaid Khan
3 odpowiedzi
0
#include <iostream> #include <string> #include <math.h> using namespace std; int main() { int varOne; int varTwo; string unknown; cout << " "; cout << "|\\" << endl << "a "; cout << "| \\ c" << endl << " "; cout << "| \\" << endl << " "; cout << "|___\\" << endl << " "; cout << " b " << endl << endl; cout << "Which variable are you looking for? "; cin >> unknown; cout << unknown << endl; if(unknown == "a" || unknown == "b"){ if(unknown == "a"){ cout << "What is b? "; } else { cout << "What is a? "; } cin >> varOne; cout << varOne << endl; cout << "What is c? "; cin >> varTwo; cout << varTwo << endl; cout << "The variable " << unknown << " is: " << sqrt((double)varTwo*varTwo - varOne*varOne); } else if(unknown == "c"){ cout << "What is a? "; cin >> varOne; cout << varOne << endl;
3rd Jul 2018, 8:04 AM
Rain
Rain - avatar
0
cout << "What is b? "; cin >> varTwo; cout << varTwo << endl; cout << "The variable " << unknown << " is: " << sqrt((double)varOne*varOne + varTwo*varTwo); } else { cout << "Error, the variable you are looking for is unrecognized. The variables you can look for are a, b, or c." << endl; } /* cout << "a: "; cin >> a; cout << a << endl; cout << "b: "; cin >> b; cout << b << endl; cout << "c: "; cin >> c; cout << c << endl; */ return 0; }
3rd Jul 2018, 8:04 AM
Rain
Rain - avatar
0
That is my code. I hope this is what you are looking for.
3rd Jul 2018, 8:05 AM
Rain
Rain - avatar