Write a program that prompts the user to input the coordinates of a line which lie on the circumference of a circle .write a program to compute area of circle (hint: use distance formula for calculating the diameter of a circle.)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x1, x2, y1, y2;
cout << "Enter x1, y1: ";
cin >> x1 >> y1;
cout << "Enter x2, y2: ";
cin >> x2 >> y2;
double D = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
const double PI = 3.145;
cout << "Area of circle is: " << PI * D * D/ 4 << endl;
return 0;
}
Comments
Good job Not bad sir!
Leave a comment