![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find the other-end coordinates of diameter in a circler in C++
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
Advertisements