计算圆的面积和周长
#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;
}

浙公网安备 33010602011771号