编写一个c++程序,提示用户输入圆的半径,然后调用内联函数circleArea计算圆面积

如题所述

//#include "stdafx.h"//If the vc++6.0, with this line.
#include <iostream>
using namespace std;
inline double circleArea(double r){
return 3.1415926*r*r;
}
int main(int argc,char *argv[]){
double x;
cout << "Input x(R:x>=0)...\nx=";
if(!(cin >> x) || x<0){
cout << "Input error, exit...\n";
return 0;
}
cout << "The area of this circle is " << circleArea(x) << endl;
return 0;
}

运行样例:

温馨提示:答案为网友推荐,仅供参考