This is my 1st program and I need some help. I've almost got this one finished but I don't know where to go from here. There is something wrong with the sides I've assigned. Any tips?  // Program: Pythagorean Theorem

// Written by: Hellbreaker

//

//

#include <iostream>

#include <cmath>


using namespace std;


void main ()

{

float m, n;

float side1;

float side2;

float hypotenuse;

cout << "****************************************\n";

cout << "Hypotenuse Finder: Pythagorean Theorem\n";

// Input side lenghts

cout << "Enter Length of side M\n";

cout << "M =";

cin >> m;

cout << "Enter Length of Side N\n";

cout << "N =";

cin >> n;

if (m > n && n >= 0)

{

// compute hypotenuse;

side1=((m*m)(n*n));

side2=(2*m*n);

hypotenuse = sqrt((side1*side1)+(side2*side2));

}

cout << "The hypotenuse is......\n";

cout << hypotenuse;

if (n>m)

{

cout <<"M must be greater than N.\n" ;

}

if (0>n)

{

cout <<"Variable N must be greater than 0.\n";

}

}
12 7384
// compute hypotenuse;
side1=((m*m)(n*n));
side2=(2*m*n);
hypotenuse = sqrt((side1*side1)+(side2*side2));
}
This looks sort of like you've crossed the Law of Cosines with the Pythagorean Theorem. m and n are the values you want to square and add, then square root.
This assumes your triangle is like this:
so i keep getting the hypo to equal 40????? I can't figure it out. here's my code now. (just trying this one out)  // Program: Pythagorean Theorem

//

//

//

#include <iostream>

#include <cmath>


using namespace std;


void main ()

{

float m, n;

float side1;

float side2;

float hypo;

float hypotenuse;

cout << "****************************************\n";

cout << "Hypotenuse Finder: Pythagorean Theorem\n";

// Input side lenghts

cout << "Enter Length of side M\n";

cout << "M =";

cin >> m;

cout << "Enter Length of Side N\n";

cout << "N =";

cin >> n;

if (m > n && n >= 0)

{

// compute hypotenuse;

side1=m;

side2=n;

hypo =((pow(m,2)) + (pow(n,2)));

hypotenuse= sqrt(hypo)

}

cout << "\nThe hypotenuse is......\n" << hypotenuse;


if (n>m)

{

cout <<"M must be greater than N.\n" ;

}

if (0>n)

{

cout <<"Variable N must be greater than 0.\n";

}

}
Sorry I've gone through it a lot but I'm about to give up. Please someone give me some hope, c++ has drained all my mana.  // Program: Pythagorean Theorem

// Written by:

//

//

#include <iostream>

#include <cmath>


using namespace std;


void main ()

{

float m, n;

float side1;

float side2;

float hypotenuse;

cout << "****************************************\n";

cout << "Hypotenuse Finder: Pythagorean Theorem\n";

// Input side lenghts

cout << "Enter Length of side M\n";

cout << "M =";

cin >> m;

cout << "Enter Length of Side N\n";

cout << "N =";

cin >> n;

while (m > n && n >= 0)

{

// compute hypotenuse;

side1=m*m;

side2=n*n;

hypotenuse= sqrt(side1+side2);

cout << "The hypotenuse is......"; hypotenuse;

}

if (n>m)

{

cout <<"M must be greater than N.\n" ;

}

if (0>n)

{

cout <<"Variable N must be greater than 0.\n";

}

if (0>m)

{

cout <<"Variable M must be greater than 0.\n";

if (m=n)

{

cout <<"Vatiable M cannot be the same as variable N.\n";

}

}
There are a few things wrong:
a) Your while... loop never terminates. m and n are never changed, and so the initial conditions of the loop never change. It is either never executed, or will continue to execute forever and ever and ever and...
b) You put a semicolon after your cout statement in the loop, so the hypotenuse is never being displayed.
c) The purpose of all your if statements is unclear. They will indeed inform the user of the situation, but since they occur after the loop, they can't actually fix anything.
d) In the last if statement, you use m=n, which is assignment. You should use m==n, which is comparison, to determine equality.
The math side of this looks correct, you just need to put a little more thought into the programming aspect of it. Think out your program's flow before you sit down at the computer and try this (i.e. in what order to things have to happen to make sense?).
In addition, there was no need to create a second thread on the same topic. You can keep us updated in this thread  any more than that is unnecessary and wastes space.
Okay so I'm kind of unclear on what I've missed. I feel really overwhelmed with this, does it get easy to write programs once you get the hang of it because I feel like I'm riding the short bus.
Here's what I've changed.
while (m > n && n >= 0)
{
// compute hypotenuse;
side1=pow(m,2);
side2=pow(n,2);
side3 =(side1+side2)/(side1+side2);
cout << "The hypotenuse is......";
cout << "\n\n";
cout << side3;
THANKS FOR ALL THE HELP, YOU GUYS ARE SAVING MY SANITY!
So i don't think I asked for any help right there but I really could use some now. I just want to use the Pythagorean theorem. 
if (m > n && n >= 0)

{

// Compute hypotenuse

side1=pow(m,2);

cout << "side one" <<side1;

side2=pow(n,2);

cout << side2;

side3 = sqrt((side1+side2));

cout << "The hypotenuse is\n" <<side3;

cout << "\n\n";
even this doesn't work right. I'm about to give up :(
Well, what doesn't work? Does it print anything out? The wrong number? Alien symbols? Does the compiler error out? What's the error?
The error is that the hypotenuse isn'tt calculated correctly.
The error is that the hypotenuse isn'tt calculated correctly.
What an astoundingly descriptive reply. So, as you haven't really given me much to go on, I'm going to go copy your code, put it into my compiler, guess as to what you have and haven't put in, rewrite some of it, and get it to work, then try to figure out if everything I guessed at is actually what you have put.
My initial guess is that the && operators are messing with the precedence in the if statement (ie make it if ( (m > 0) && (n > 0) ) so that there are definitely not an 'order of operations' errors). That's just as guess as you're not saving that anywhere, so it shouldn't affect it (except for the true/false part of the condition  maybe the loop is never even running, but I can't even tell if everything is getting initialized properly as you are not saying what number you're putting in, what you are getting out, etc... because you didn't post the new program you created.)
What I'd recommend (as I will probably fall asleep before I get your code to work), is to put print statements after each line and print out all the variables (even if you're not using them on that line) so that you can see 1) what is being executed and 2) what the values are before/after they are executed.
lol it's cool now, i'm just crazy cause I had to figure it out. THANKS GUYS, now I'm crazy. it finally works 
// Program: Pythagorean Theorem

// Written by:

//

//


#include <iostream>

#include <cmath>


using namespace std;


void main ()

{

float m, n;

float side1;

float side2;

float side3;

// Program Starts

cout << "****************************************\n";

cout << "Hypotenuse Finder: Pythagorean Theorem\n";

// Explanation of program's mathmatics

cout << "\nA^2+B^2=C^2 (Principle of the Pythagorean Theorem)\n";

// Input side lenghts

cout << "\nEnter Length of Side M\n\n";

cout << "M=";

cin >> m;

cout << "\nEnter Length of Side N\n\n";

cout << "N=";

cin >> n;

if (m > n && n >= 0)

{

// Compute hypotenuse

side1=pow(m,2);

side2=pow(n,2);

side3 = sqrt((side1+side2));

cout << "\nDrumroll please....................\n\n\n";

cout << "\nThe Hypotenuse is " <<side3;

cout << "\n\nSide 1 is " <<side1;

cout << "\nSide 2 is " <<side2;

cout << "\n\n";

cout << "************************************\n";

}


// Clean up user input

else if (n > m)

{

cout <<"\nM must be greater than N.\n\n" ;

}

else if (0 > n)

{

cout <<"\nVariable N must be greater than 0.\n\n";

}

else if (0 > m)

{

cout <<"\nVariable M must be greater than 0.\n\n";

}

else if (m == n)

{

cout <<"\nVatiable M cannot be the same as variable N.\n\n";

}

}

it is my 1st.
lol it's cool now, i'm just crazy cause I had to figure it out. THANKS GUYS, now I'm crazy. it finally works
it is my 1st.
Congrats, I'm glad it finally works. Sorry for going off on you last night  it was getting late and I was losing Desktop Tower Defense pretty badly.
Okay, not really (I rock at that game), but I was tired and couldn't get to sleep, but I'm still sorry and glad you got it to work. Please feel free to post again if you get stuck on your next project!
Right on, thanks man. I appreciate it
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason Heyes 
last post by:
A pythagorean triple is a triple <a,b,c> whose components are positive
integers satisfying a*a + b*b = c*c. An example is <3,4,5> since 3*3 + 4*4 =
9 + 16 = 25 = 5*5.
I want to write a function...

by: Santosh Krisnan 
last post by:
hello all,
I fiddled with BASIC in the early 90s but left it at
that. Now I am trying to learn C. I tried to solve an
exercise in my book, but it failes to compile. Can
anyone tell me what the...

by: 3than7 
last post by:
I am writing an application to solve Pythagorean Theorum Problems. This
is on my own time, i am using a book to learn c++, and after doing a
fahrenheit to celsuis program from that book, i wanted...

by: teddarr 
last post by:
I'm having trouble getting a mathmatical formula to work in my code.
I am supposed to write a program in java that calculates the ending balance each month. The user is supposed to input the...

by: Carramba 
last post by:
theorem states that:
Integer n is prime if and only if (x +1)^n â‰¡ x^n +1 (mod n) in Z.
so I testing it, but values doesn't match ... and I don't se why.. I
guess :) it's some thing wrong in...

by: stephanieanne2 
last post by:
The Problem: A right triangle can have sides that are all integers. The set of three integer values for the sides of a right triangle is called a Pythagorean triple. These three sides must satisfy...

by: inferi9 
last post by:
hi everyone I am new here and I have this C++ program that I have to write but it keep given me nothing useful. here is the question:
A right triangle can have sides that are all integers. A...

by: Pieter 
last post by:
Hi,
I'm currently making a basic pattern generator. When you open the
program it draws the selected pattern in a box, you can make the box
also bigger and smaller just by dragging at the...

by: CloudSolutions 
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

by: Faith0G 
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

by: isladogs 
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...

by: ryjfgjl 
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...

by: taylorcarr 
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...

by: aa123db 
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...

by: ryjfgjl 
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and timeconsuming...

by: ryjfgjl 
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...

by: Sonnysonu 
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by columnwise with in the specific length.
suppose the i have to...
 