Programming C++  «Prev 

C++ Cimple Output Program

//A first C++ program illustrating output

#include <iostream.h>

int     //The return type for main
main()
{
   cout << "C++ is an improved C.\n";
   return(0); //signals successful termination
}

//A first C++ program illustrating output

The double slash (//) is a new comment symbol. The comment runs to the end of the line. The old C bracketing comments symbols /* */ are still available for multi-line comments.
#include <iostream.h>

The iostream.h header file introduces I/O facilities for C++.
cout << "C++ is an improved C.\n";

This statement prints to the screen. The identifier cout is the name of the standard output stream. The operator << passes the string "C++ is an improved C.\n" to standard output. Used in this way, the output operator << is referred to as the put to or insertion operator.

return(0); //signals successful termination

A value of zero is returned to the system, indicating the successful completion of the program. Most systems allow you to ignore this requirement or give you a warning if you fail to return a value from main().