This is a C Program to Check if a Point d lies Inside or Outside a Circle Defined by Points a, b, c in a Plane. For any point t (xt, yt) on the plane, its position with respect to the circle defined by 3 points (x1, y1) , (x2, y2), (x3, y3).

s = (x-xt)^2 + (y-yt)^2 – r*r

If s < 0, t lies inside the circle; if s > 0, t lies outside the circle; if s = 0, t lies on the circle.

s = (x-xt)^2 + (y-yt)^2 – r*r

If s < 0, t lies inside the circle; if s > 0, t lies outside the circle; if s = 0, t lies on the circle.

Here is source code of the C Program to Check if a Point d lies Inside or Outside a Circle Defined by Points a, b, c in a Plane. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`#include <string.h>`

`#include <stdio.h>`

`#include <stdlib.h>`

const int LOW = 0;

const int HIGH = 10;

int main(int argc, char **argv) {

`time_t seconds;`

time(&seconds);

srand((unsigned int) seconds);

double x1, x2, y1, y2, x3, y3;

double m1, m2, c1, c2, r;

x1 = rand() % (HIGH - LOW + 1) + LOW;

x2 = rand() % (HIGH - LOW + 1) + LOW;

x3 = rand() % (HIGH - LOW + 1) + LOW;

y1 = rand() % (HIGH - LOW + 1) + LOW;

y2 = rand() % (HIGH - LOW + 1) + LOW;

y3 = rand() % (HIGH - LOW + 1) + LOW;

m1 = (y1 - y2) / (x1 - x2);

m2 = (y3 - y2) / (x3 - x2);

c1 = ((m1 * m2 * (y3 - y1)) + (m1 * (x2 + x3)) - (m2 * (x1 + x2))) / (2

* (m1 - m2));

c2 = ((((x1 + x2) / 2) - c1) / (-1 * m1)) + ((y1 + y2) / 2);

r = sqrt(((x3 - c1) * (x3 - c1)) + ((y3 - c2) * (y3 - c2)));

printf("The points on the circle are: (%lf, %lf), (%lf, %lf), (%lf, %lf)\n",

x1, y1, x2, y2, x3, y3);

printf("The center of the circle is: (%lf, %lf) and radius is: %lf", c1,

c2, r);

printf("\nEnter the point : <x>,<y>");

int x, y;

scanf("%lf", &x);

scanf("%lf", &y);

double s = ((x - c1) * (x - c1)) + ((y - c2) * (y - c1)) - (r * r);

if (s < 0)

printf("\nThe point lies inside the circle");

else if (s > 0)

printf("\nThe point lies outside the circle");

`else`

printf("\nThe point lies on the circle");

return 0;

`}`

Output:

$ gcc PointWRTCircle.c $ ./a.out The points on the circle are: (10.000000, 0.000000), (8.000000, 4.000000), (7.000000, 2.000000) The center of the circle is: (9.250000, 1.875000) and radius is: 2.253470 Enter the point : <x>,<y> 2 3 The point lies outside the circle

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

Here’s the list of Best Reference Books in C Programming, Data Structures and Algorithms.