•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,631 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,254 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
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; }
Comments (Newest First)
manutd | Junior Poster in Training | Nov 21st, 2006
•
•
•
•
There are some outdated elements (goto), non-portable ones (system("PAUSE"), and a complete lack of indentation.
bumsfeld | Posting Shark | May 18th, 2006
•
•
•
•
Pythagoras is the man's real name.
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)