#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;
}
Comments
Leave a comment