rectangle

Nov 1, 2014 at 9:46am
how to check the if rectangle is a square or not?

Nov 1, 2014 at 9:56am
Check if the side lengths are the same.
Nov 1, 2014 at 9:57am
All it's sides have equal length.
Nov 1, 2014 at 2:50pm
that i know but how to do the coding for that
Nov 1, 2014 at 3:01pm
if (width==height) cout << "square\n";
How do you define your rectangle?
Nov 1, 2014 at 7:45pm
Try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
int main{
std::cout << ("Enter side 1: ") << std:endl;
std::cin >> s1;
std::cout << ("Enter side 2: ") << std:endl;
std::cin >> s2;
std::cout << ("Enter side 3: ") << std:endl;
std::cin >> s3;
std::cout << ("Enter side 4: ") << std:endl;
std::cin >> s4;
if((s1 | s2) ==  ( s3 | s4)) //Check a pair of sides are congruent.
{
std::cout << ("It's a square!") << std::endl;
}
else
{
std::cout << ("It's a rectangle!") << std::endl;
}
return(0);
}
Nov 2, 2014 at 4:09am
deleted:]
Last edited on Nov 2, 2014 at 3:21pm
Nov 2, 2014 at 9:19am
A square is a rectangle but a rectangle is not necessary a square.
Nov 2, 2014 at 2:23pm
What kind of rectangle?
Are you using a 2D graphic engine?
Or is it just a console app?
And do you know the coordinates of the rectangle and the width/height of it?
Topic archived. No new replies allowed.