<<== <= [table of contents] [search] [glossary] [feedback] => ==>>

[online C++ tutorial]Section 2: A First Program

Section 2.1: "Hello, Dave"

Before diving right into the nitty-gritty of C++ language details, let's get started with a full-fledged C++ program! The idea of this program is to introduce you to the overall structure of a C++ program and give you the flavor of C++.

Here, then, is an entire C++ program:

//include this file for cout
#include <iostream.h>

int main() {

  //print out the text string, "Hello, World!"
  cout << "Hello, World!" << endl;

  return 0;

}

To prepare for the next section, create a new text file and save this code into the file. If you are on a unix machine, save the file with the filename hello.C (make sure it ends with .C, not .c!). If you are on a Windows machine, save the file with the filename hello.cpp.

You're now ready to compile and run your program, covered on the next page.


<<== <= [table of contents] [search] [glossary] [feedback] => ==>>