Circle

Points: 1 (partial)
Time limit: 1.0s
Memory limit: 98M

Problem types

Enter the real number as the radius R of a circle. calcule circumference and the area of that circle with the precision of 2 digits after the decimal point, in case R <0, print " NO CIRCLE ”.

Input:

A line of a real number R

Output:

Either 1 result "NO CIRCLE" or two lines corresponding to the circumference, the area of the circle is rounded to 2 digits after the decimal point.

-3.5

NO CIRCLE

3.0

Output:

18.85

28.27

• commented on Sept. 6, 2021, 5:56 a.m.

include<iostream>

using namespace std;

int main(){

int r;
cout<<"nhap R: ";
cin>> r;

if(r<0){
cout<<"NO CIRCLE";
}
else{

float s;
float p;

p= 3.14*2*r;
s= 3.14 * r*r;

cout<<"p= "<< p <<" " <<"s= "<<s;

}
return 0;

}

• commented on Jan. 13, 2019, 9:14 a.m.

include<iostream>

using namespace std;

int main()

{

float n,cv,dt;
cin>>n;

if(n >= 0)
{
cv = 2 * 3.14 * n;
dt = 3.14 * n * n;
cout<<cv<<endl<<dt<<endl;
}
else
{
cout<<"NO CIRCLE";
}
return 0;

}