Question #124370

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>
#include <cmath>


using namespace std;


int main(){
    double s, ri, ro;


    cout << "Input ri: "; cin >> ri;
    cout << "Output ro: "; cin >> ro;
    s = M_PI * (ro * ro - ri * ri);
    cout << "Answer: " << s;
}

LATEST TUTORIALS
APPROVED BY CLIENTS