Complete listing of Includes01.cpp
/*Note: This is the beginning of a multi-line comment, surrounded by the multi-line comment delimiters. File: Includes01.cpp This is a very simple C++ program. It illustrates the following programming elements in C++: The include compiler directive The global main function Simple output using cout Code blocks Comments Other than comments and code blocks, everything in the above list is peculiar to C++. To compile this program, use an IDE such as MS Visual Studio 6.0. You can then execute the program from within VS 6.0. When you do, the following text will be displayed on the screen: Hello World Press any key to continue A successful compilation and execution from within VS 6.0 will produce ten new files plus one new directory named Debug. You can also execute the compiled program by making Debug the current directory and entering the following command at the command prompt: Includes01 Note: This is the end of the multi-line comment*/ //Note: This is a single-line comment. //Note, the following compiler directive is // required in order to cause library elements // to be loaded that make it possible to do // simple input/output in C++. #include <iostream> using namespace std; //Every C++ program requires a global main // function. One syntax for the main function // follows. This is not the only syntax that // can be used for the main function in C++. int main(){//Note: Another single-line comment //Everything inside this matching pair of // curly braces constitutes a block of // code. //Everything inside the following matching // pair of curly braces constitutes a // nested block of code with no purpose other // than to illustrate the nesting of code // blocks. {//Begin nested code block //Display something on the screen cout << "Hello World\n"; }//end nested code block return 0; }//end main Listing 5 |
-end-