WAP- The line joining the points (2,2) and (5,6) which lie on the circumference of the circle is the diameter of the circle. Write a program to compute the area of the circle.


//E Balagurusamy, Programming In ANSI C,4E
//Exercise 1.13, page 22

#include <stdio.h>
#include <math.h>
#define PI 3.14
//point 1
#define x1 2
#define y1 2
//point 2
#define x2 5
#define y2 6
int main(void)
{int term1,term2,d,r;
float perim;

printf("\n\n");
term1=(x2-x1)*(x2-x1);
term2=(y2-y1)*(y2-y1);
d=sqrt(term1+term2);
r=d/2;
perim=2*PI*r;
printf("The given points (%d,%d) and (%d,%d) form the diameter,\n",x1,y1, x2,y2);
printf("and the Perimeter is %f",perim);
printf("\n\n");
return 0;
}

Comments