The equation used in this problem is:
Shaded area= area of the Square - Area of the circle
#include<iomanip>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int t,i;
cin>>t;
for(i=1;i<=t;i++){
double r,pi,ca,sa,ra;
cin>>r;
pi=2*acos(0.0);
ca=pi*(r*r);
sa=(2*r)*(2*r);
ra=sa-ca;
cout<<"Case "<<i<<": "<<fixed<<setprecision(2)<<ra<<endl;
}
return 0;
}
No comments:
Post a Comment
If you have any doubts, let me know through comments