Start here:

#include <iostream>
 
using namespace std;
 
double circle_area(double radius) {
	const double PI = atan(1.0) * 4;
	double area;
 
	area = PI*radius*radius;
 
	return area;
}
 
 
int main() {
	double radius;
 
	cout << "I would like to compute the area of a circle for you.\n\n";
	cout << "Please give the radius of the desired cylinder: ";
	cin >> radius;
 
	cout << "The area is " << circle_area(radius) << endl << endl;
 
	system("pause");
	return 0;
}

End here:

#include <iostream>
 
using namespace std;
 
double circle_area(double radius) {
	const double PI = atan(1.0) * 4;
	double area;
 
	area = PI*radius*radius;
 
	return area;
}
 
 
double cylinder_volume(double radius, double height) {
	double volume;
 
	volume = height * circle_area(radius);
 
	return volume;
}
 
int main() {
	double radius, height;
 
	cout << "I would like to compute the volume of a cylinder for you.\n\n";
	cout << "Please give the radius of the desired cylinder: ";
	cin >> radius;
	cout << "Please give the height of the desired cylinder: ";
	cin >> height;
 
	cout << "The volume is " << cylinder_volume(radius, height) << endl << endl;
 
	system("pause");
	return 0;
}
cs-142/cylinder.txt · Last modified: 2015/02/12 09:21 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0