- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

We have two circles. The center of both of them is at the origin. The radius of these two circles is given. They are r and R, R > r. Another circle is also present. Its radius (r1) and the center point are given, we have to check whether that point is inside the ring formed by the first two circles or not.

We can solve this using the Pythagorean theorem. compute the distance from the center of the circle and origin. Then if (distance – r1) >= r and (distance – r1) <= R, if both are true, then the circle is inside the ring.

#include <iostream> #include <cmath> using namespace std; bool isInside(int r, int R, int r1, int x, int y) { int dis = sqrt(x*x+y*y); return (dis-r1 >= R && dis+r1 <= r); } int main() { int r = 8, R = 4, r1 = 2, x = 6, y = 0; if (isInside(r, R, r1, x, y)) cout << "Circle is inside the ring." << endl; else cout << "Circle is not inside the ring." << endl; }

Circle is inside the ring.

- Related Questions & Answers
- Check if a circle lies inside another circle or not in C++
- Find if a point lies inside a Circle in C++
- Check if a given point lies inside a Polygon
- Check whether given circle resides in boundary maintained by two other circles in Python
- Check whether a given point lies inside a Triangle
- Program to calculate the area between two Concentric Circles in C++?
- C++ Program to Check if a Point d lies inside or outside a circle defined by Points a, b, c in a Plane
- Check if a point lies on or inside a rectangle in Python
- How to draw concentric circles in R?
- How to draw concentric circles with dark borders in R?
- How to draw concentric circles with dark borders in R?
- Check if given string can be formed by concatenating string elements of list in Python
- Check if any interval completely overlaps the other in Python
- Check if a line touches or intersects a circle in C++
- Create a text inside circles in HTML5 Canvas

Advertisements