课堂作业1

题目描述: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 should be divided into two source files (.cpp). Hand in the source files and the head files which you create.

代码如下:

main.cpp:

#include <iostream>
#include "cal.h"
using namespace std;

int main()
{
	double s, r;
	cout << "please input the radius" << endl;
	while (cin >> r)
	{
		cout << "The area is " << calS(r) << endl;
	}
	return 0;
}

cal.cpp:

#include <iostream>
#include "cal.h"
#define pi 3.14
using namespace std;

double calS(double r)
{
	double s;
	s = r * r * pi;
	return s;
}

cal.h:

double calS(double r);
原文地址:https://www.cnblogs.com/kurisu/p/5464058.html