# Find the other-end coordinates of diameter in a circler in C++

C++Server Side ProgrammingProgramming

Suppose we have the center coordinate and one coordinate point on the perimeter of the circle. We have to find the another point on the perimeter. Consider the center points are (p, q), and one given point is (a, b). We have to find the point (x, y). As we know that the center is the middle point of the diameter. So we can write them like −

(p,q)=(a+x/2,b+y/2)

Or from this the (x, y) can be expressed as −

x=2p-a,y=2q-b

## Example

#include<iostream>
using namespace std;
int getCylinderPerimeter(int d, int h) {
return (2*d) + (2*h);
}
int main() {
int diameter = 5, height = 10;
cout << "Perimeter: " << getCylinderPerimeter(diameter, height) << " units";
}

## Output

Perimeter: 30 units
Published on 04-Nov-2019 12:33:14