Answer to Question #187068 in C++ for Rida saeed

Question #187068

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.)


1
Expert's answer
2021-04-29T20:50:04-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Asma M.Hussain
02.05.21, 15:16

Good job Not bad sir!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS