Answer to Question #124432 in C++ for Agyei Ebenezer

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.
1
Expert's answer
2020-06-30T07:59:27-0400

#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS