Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:cylinder [2015/02/12 15:49]
kseppi created
cs-142:cylinder [2015/02/12 16:21] (current)
kseppi
Line 1: Line 1:
 +Start here:
 +
 +<code cpp>
 +#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;
 +}
 +</​code>​
 +
 +End here:
 +
 <code cpp> <code cpp>
 #include <​iostream>​ #include <​iostream>​
cs-142/cylinder.txt ยท Last modified: 2015/02/12 16: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