if statement code

I have to write a program that asks the user to input length, width, and height and then the program determines whether it is a rectangle or a square
and then it has to determine if its a cube... i get how to ask if its a rectangle or cube but how do i incorporate a cube ?

this is what i have for this part :


if (length == width)
cout << "Your object is a square! \n";
else
cout << "Your object is a rectangle! \n";


Boolean And (&&).

When you have two condition expressions, cond1 and cond2, that each return bool then cond1 && cond2 returns true only if both conditions are true.

Pseudo: IF (bottom is a square AND side is a square)


Note also that && is lazy; if cond1 is false, then cond2 is never evaluated because the result of && is already known to be false.


PS. A 3D object can have simultaneously square, rectangle and parallelogram (or trapezoid) faces.
http://www.mathsisfun.com/quadrilaterals.html

Your program though probably assumes that every angle is a right angle, i.e. only cubes or cuboids.
http://www.mathsisfun.com/geometry/cuboids-rectangular-prisms.html
Topic archived. No new replies allowed.