Selection problem

hye there...I have a question.. I'm the beginner of c++ programming.

Question 1:
In a right triangle, the square of the length of one side is equal to the sum of the square of the length of the other two sides. write a program that prompts the user to enter the length of three sides of a triangle and then outputs a message indicates whether the triangle is a right triangle.

This is an answer that i come out. please correct if i'm wrong. please..

#include <cstdlib>
#include <iostream>

using namespace std;

main()
{
int side1,side2,side3;
cin>>side1;
cin>>side2;
cin>>side3;
if'[(a*a)+(b*b)]=(c*c)'
cout<<"right triangle:";
else
cout<<"wrong triangle:";
system("PAUSE");
return EXIT_SUCCESS;
}
Have you tried to compile this?

Your syntax of the if statement is not correct and you refer to variables 'a', 'b', and 'c' which do not exist.

The general syntax of an if-else statement is:

1
2
3
4
5
if ( expression ) {
    statement-block ;  
} else {
    statement-block ;
}


braces are needed around statement-block only if statement-block contains more than one line of code, otherwise they are optional. In your code above, you have only one line of code, so you can safely omit them.
i had compile this...but it keep wrong at the equation line...
Look at what jsmith has posted; the way you wrote that line is incorrect.
ok...thanks everybody...
i had found the answer
Topic archived. No new replies allowed.