您的位置:首页 > 编程语言 > C语言/C++

C++开学第一次作业(5.4)

2016-05-05 22:42 363 查看

开学第一次作业(5.4)

代码传送门

题目


Create a program that asks for the radius of a circle and prints the area of that circle, using cin and cout.

The whole program shouldbedividedinto two source files (.cpp).

Hand in the source files and the head files which youcreate


主函数

#include <iostream>
#include"area.h"
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv)
{
double r;
cin >> r;
cout << area(r) << endl;
return 0;
}

外部函数

#include"area.h"
double area(double r)
{
cout << r*r*PI ;
}

头文件

#include<cmath>
#include<iostream>
#define PI acos(-1)
using namespace std;
double area(double r);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: