Solution (Area of a Circle) of URI online judge problem 1002 by c++

The area of the circle is defined as A = π . R2, having π as 3.14159.

Calculate the area using the formula given in the problem description.

Input

Read the variable R (double precision), that is the radius of the circle.

Output

Print the variable A, rounded to four decimal digits.

Sample Inputs Sample Outputs
2.00 A=12.5664
100.64 A=31819.3103
150.00 A=70685.7750

Solution:

#include<iostream>
#include <iomanip>
using namespace std;
int main(){
double R, A, pi;
pi=3.14159;
cin>>R;
A=pi*(R*R);
cout<<“A=”<<fixed<<setprecision(4)<<A<<endl;
return 0;
}

Advertisements
Categories: URI | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.