计算圆的面积和周长

#include<iostream>
const double PI = 3.14;
using namespace std;

int main()
{
//declare variables
double r, l, s;

// enter the radius of circle
cout << "r = ";
cin >> r;

//calculate the cirumference of a circle

l = 2 * PI * r;
cout << "l =" <<l << endl;

//calculate the area of circle

s = PI * r * r;
cout << "s = " << s << endl;

return 0;


}

posted @ 2021-06-29 16:07  江南王小帅  阅读(53)  评论(0)    收藏  举报