Chapter 5
Chapter 5
Dev C++
Visual C++
VisualAge C++
Code Blocks,
{
cout << "Hello World!";
return 0;
}
output
Hello World!
All the lines beginning with two slash signs (//) are considered comments
and do not have any effect on the behavior of the program.
#include <iostream>
Sentences that begin with a pound sign (#) are directives for the preprocessor.
the sentence #include <iostream> tells the compiler's preprocessor to include the iostream standard header
file. This specific file includes the declarations of the basic standard input-output library in C ++,
This line corresponds to the beginning of the main function declaration. The main
function is the point by where all C++ programs begin their execution.
Also, for that same reason, all C++ programs must have a main function. main’ is
followed by a pair of parentheses () because it is a function.
This instruction does the most important thing in this program. cout is the standard output stream in C++ (usually
the screen), and the full sentence inserts a sequence of characters (in this case "Hello World") into this output
stream (the screen).
return 0;
The return instruction causes the main () function to finishing and returns the code that the instruction is
followed by, in this case, 0.
<iostream> This file defines the cin, cout, cerr, and clog objects, which correspond
to the standard input stream, the standard output stream, the un-buffered
standard error stream, and the buffered standard error stream,
respectively.
<iomanip> This file declares services useful for performing formatted I/O with so-
called parameterized stream manipulators, such as setw and set
precision.
Integer
bool
Unsigned
Signed
#include <iostream>
using namespace std;
int main(){
const int LENGTH = 10;
const int WIDTH = 5;
const char NEWLINE = '\n';
27