previous | index | next

A Complete Program

/* 
 * 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.

previous | index | next