Answer to Question #124433 in C++ for GLI GODWIN BRAIN

Question #124433
3. Write a program that computes the area of a circular region (the shaded area in the diagram) given the radius of the inner and the outer circles, ri and ro, respectively.






3. Write a program that computes the area of a circular region (the shaded area in the diagram) given the radius of the inner and the outer circles, ri and ro, respectively.
1
Expert's answer
2020-06-30T07:59:16-0400
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	float r1;  // inner radius 
	float r2;  // outer radius
	float area; // area of the region
	cout << "Enter the inner radius of the circular region \n" ;
	cin >> r1 ;
	cout << "Enter the outer radius of the circular region \n" ;
	cin >> r2 ;
	if (r1 > r2)
	{
		cout << "Inner radius must be less than outer radius "<< endl;
	}  
	else
	{
		area = (M_PI)*(r2*r2 - r1*r1 );   // calculating the area of shaded region
		cout << "Area of the shaded region is " << area << " square unit " <<endl;    // printing area of the region
	}
	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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS