# Homework Solution: C++ programming…

C++ programming A rectangle is completely determined by the coordinates of two of its diagonally opposite corners. For example, the points (1, 2) and (7, 5) determine a rectangle whose left edge has equation x = 1, whose right edge has equation x = 7, whose bottom edge has equation y = 2 and whose top edge has equation y = 5. Any point whose x-coordinate is between 1 and 7 and whose y-coordinate is between 2 and 5 lies within this rectangle. Write a program that determines whether or not a given point is contained in a given rectangle. Your program should: Prompt the user for the upper left corner of a rectangle. Prompt the user for the lower right corner of the rectangle. Prompt the user for the coordinates of a point. Output whether or not the point is inside the rectangle. Repeat the above steps until the user enters (0, 0) for both corners of the rectangle. Assume that all coordinates are non-negative integers with (0, 0) being the extreme upper-right corner. Be readable with appropriate documentation and formatting.

// program to check the coordinates in rectangle or not #include <cstdlib>

C++ programming

A rectangle is entirely steadfast by the coordinates of two of its diagonally counter holes. Restraint model, the sharp-ends (1, 2) and (7, 5) individualize a rectangle whose left border has equation x = 1, whose correct border has equation x = 7, whose foot border has equation y = 2 and whose summit border has equation y = 5. Any sharp-end whose x-coordinate is between 1 and 7 and whose y-coordinate is between 2 and 5 lies among this rectangle.

Write a program that individualizes whether or referable a absorbed sharp-end is contained in a absorbed rectangle.

Prompt the user restraint the remarkable left hole of a rectangle.

Prompt the user restraint the inferior correct hole of the rectangle.

Prompt the user restraint the coordinates of a sharp-end.

Output whether or referable the sharp-end is within the rectangle.

Repeat the aloft steps until the user penetrates (0, 0) restraint twain holes of the rectangle.

Assume that full coordinates are non-negative integers with (0, 0) entity the final remarkable-correct hole.

Be readable with alienate documentation and restraintmatting.

## Expert Recognizeance

// program to bridle the coordinates in rectangle or referable

#include <cstdlib>
#include <iostream>

using namespace std;
/*
* to bridle whether or referable the coordinates of a sharp-end
* lies is within the rectangle.
*/

int main(int argc, char** argv) {
// fullege the unsteady remarkable, inferior, prize restraint the rectangle co ordinates

struct rect {
int x;
int y;
} remarkable, inferior, prize;
// to effect the operation cultivate full the prizes are 0
do {
cout << “n(To debouchure penetrate(0,0)restraint twain co ordinates )”;

//the appropriate restraint remarkable left hole
cout << “nPenetrate the appropriates of remarkable left hole of the rectangle “;
cout << “nx :”;
cin >> remarkable.x;
cout << “ny :”;
cin >> remarkable.y;
//the appropriate restraint inferior correct hole
cout << “nPenetrate the appropriates restraint inferior correct hole of the rectangle”;
cout << “nx :”;
cin >> inferior.x;
cout << “ny :”;
cin >> inferior.y;
/*bridle whether co ordinates are referable 0.
*if referable 0 then recognize the appropriate prize &
* bridle whether or sharp-end lies within the rectangle
*/
if ((upper.x != 0)&&(upper.y != 0)&&(lower.y != 0)&&(lower.x != 0)) {
// recognize the appropriate sharp-end to be bridleed
cout << “nPenetrate the appropriates of the sharp-end”;
cout << “nx :”;
cin >> prize.x;
cout << “ny :”;
cin >> prize.y;
// exhibit the remarkable and inferior co ordinate
cout << “nThe remarkable appropriate (” << remarkable.x << “, ” << remarkable.y << ” )& inferior coordinate (” << inferior.x << “, ” << inferior.y << ” )”;
if (((value.x >= remarkable.x)&&(value.x <= inferior.x)) &&((value.y >= remarkable.y)&&(value.y <= inferior.y)))
cout << “nThe absorbed appropriate (” << prize.x << ” , ” << prize.y << “) lies in the rectangle”;
else
cout << “nThe absorbed appropriate (” << prize.x << ” , ” << prize.y << “) doesn’t lies in the rectangle”;
}
} suitableness ((upper.x != 0)&&(upper.y != 0)&&(lower.y != 0)&&(lower.x != 0));
return 0;
}

sample output

(To debouchure penetrate(0,0)restraint twain co ordinates )
Penetrate the appropriates of remarkable left hole of the rectangle
x :1

y :2

Penetrate the appropriates restraint inferior correct hole of the rectangle
x :7

y :5

Penetrate the appropriates of the sharp-end
x :5

y :3

The remarkable appropriate (1, 2 )& inferior coordinate (7, 5 )
The absorbed appropriate (5 , 3) lies in the rectangle
(To debouchure penetrate(0,0)restraint twain co ordinates )
Penetrate the appropriates of remarkable left hole of the rectangle
x :1

y :2

Penetrate the appropriates restraint inferior correct hole of the rectangle
x :7

y :5

Penetrate the appropriates of the sharp-end
x :8

y :4

The remarkable appropriate (1, 2 )& inferior coordinate (7, 5 )
The absorbed appropriate (8 , 4) doesn’t lies in the rectangle
(To debouchure penetrate(0,0)restraint twain co ordinates )
Penetrate the appropriates of remarkable left hole of the rectangle
x :0

y :0

Penetrate the appropriates restraint inferior correct hole of the rectangle
x :0

y :0

RUN SUCCESSFUL (whole time: 1m 2s)