0

Well its fairly self explanatory, its a program that shows that calculates the hypotenuse using the pythagorean theorum, It displays the values of the sides and shows a crappy ascii art right triangle with the values input and the later found values

#include <math.h>
#include <iostream>
using namespace std;
int main()
{
cout<<"This program will find the hypotenuse of a right triangle.\n";
cout<<" |\\\n";
cout<<" | \\\n";
cout<<"A|  \\C\n";
cout<<" |   \\\n";
cout<<"  ----\n";
cout<<"   B\n";
int a, b, c, x, y, z, answer;
starta: cout<<"Enter value of side A:";
cin>> a;
if (a<=0){cout<<"A side cannot to be less than or equal to 0\n";goto starta;}
startb:cout<<"Enter value of side B:";
cin>> b;
if (b<=0){cout<<"A side cannot to be less than or equal to 0\n";goto startb;}
cout<<" |\\\n";
cout<<" | \\\n";
cout<<a<<"|  \\C\n";
cout<<" |   \\\n";
cout<<"  ----\n";
cout<<"   "<<b<<"\n";
x=a*a;
y=b*b;
z=x+y;
cout<<pow(a,2)<<"+"<<pow(b,2)<<"="<< z <<".\n";
z=x+y;
pow(z,0.5);
cout<<" |\\\n";
cout<<" | \\\n";
cout<<a<<"|  \\"<<sqrt(z)<<"\n";
cout<<" |   \\\n";
cout<<"  ----\n";
cout<<"   "<<b<<"\n";
cout<<"Side C is "<< sqrt(z) <<".\n";
system("PAUSE");
return 0;
}
3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by manutd
0

There are some outdated elements (goto), non-portable ones (system("PAUSE"), and a complete lack of indentation.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.