Data Struc

This is this part I have question:
Why it didnt calculate the area?
What did i wrong?
here is output

Welcome
What is the upper left coordinate do you like to input
3
2
What is the lower right coordinate do you like to input
5
7
X: 0 Y: 0


1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
Point xny;
cout <<"X: " << xny.x <<" " << "Y: " << xny.y << endl;
    
    return 0;
}
Point findarea (Rectangle r)
{
    const int midpoint_x = ( r.uppper_left.x + r.lower_right.x ) / 2;
    const int midpoint_y = ( r.uppper_left.y + r.lower_right.y ) / 2;
    
    const Point its_center = { midpoint_x, midpoint_y } ;
    return its_center;
}
Last edited on
Chubby wrote:
This is this part I have question:
Why it didnt calculate the area?
What did i wrong?
here is output

Welcome
What is the upper left coordinate do you like to input
3
2
What is the lower right coordinate do you like to input
5
7
X: 0 Y: 0


1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
Point xny;
cout <<"X: " << xny.x <<" " << "Y: " << xny.y << endl;
    
    return 0;
}
Point findarea (Rectangle r)
{
    const int midpoint_x = ( r.uppper_left.x + r.lower_right.x ) / 2;
    const int midpoint_y = ( r.uppper_left.y + r.lower_right.y ) / 2;
    
    const Point its_center = { midpoint_x, midpoint_y } ;
    return its_center;
}
Is this a joke question? Your findarea function calculates the midpoint, and you only output a default-constructed point. I'm not trying to be mean or rude, I just find it hard to believe.
Last edited on
You didn't show us any code that handles the inputting of the x and y coordinates. You showed us a function which, as @LB points out, is completely misnamed, and is never called in you code.

You didn't give us nearly enough information to know what you were trying to do, much less figure out what it was you were actually doing.

Please show us more code and describe what it is you are trying to do.
Topic archived. No new replies allowed.