/*
* File: cylinder-program.cpp
* Author: T. Colburn
*
* Created on October 10, 2008, 6:32 PM
*/
#include <iostream>
using namespace std;
// ****************************************************
double square(double x) {
return x * x;
}
double cylinderVolume(double radius, double height) {
return 3.14159 * square(radius) * height;
}
int main(int argc, char** argv) {
cout << cylinderVolume(5, 4);
}
|
|
- All text between "/*" and "*/" is interpreted as a
comment.
- The "#include <iostream>" line is (partially) analogous to a
(require (lib ...)) line in Racket. It tells the C++ compiler to
include a file called iostream in your program. This makes the
predefined std::cout stream available.
- The "using namespace std;" line allows your program to refer
to cout instead of std::cout.
- The definition of square precedes its use
in cylinderVolume.
- The definition of cylinderVolume precedes its use
in main.
|