Question #124432

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.










We compute the area of the circular region by subtracting the area of the inner circle from the area of the outer circle.

Expert's answer

#include <iostream>


int main()

{

double ri = 10;

double ro = 20; 


if(ri > ro)

{

std::cout << "Error: inner radius bigger than outer radius\n";

return 1;

}


const double Pi = 3.1415926;

double area = (Pi * ro * ro) - (Pi * ri * ri);

std::cout << "Result Area is: " << area << "\n";

  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!

LATEST TUTORIALS
APPROVED BY CLIENTS