WAP- A point on the circumference of a circle whose center is (0,0) is (4,5). Write a program to computer perimeter and area of the circle.

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

#include <stdio.h>
#include <math.h>
#include <conio.h>

//single-point control,
//as suggested by Code Complete 2

#define center_x 0
#define center_y 0

#define point_on_circle_x 4
#define point_on_circle_y 5

#define PI 3.14

int main(void)
{float radius=0.0, term1=0, term2=0;

printf("nn");

term1= (point_on_circle_x - center_x) * (point_on_circle_x - center_x);
term2= (point_on_circle_y - center_y) * (point_on_circle_y - center_y);
radius=sqrt(term1 + term2);

printf("Perimiter : %fn",2*PI*radius);
printf("Area : %f",PI*radius*radius);

getch();
return 0;
}

Comments