Solutions to exercises in Chapter 0, "Getting started. "
Exercise 0-0
Compile and run the Hello, world! program.
Hint
Make sure that you locate the documentation and help files for your
compiler and editing environment.
Solution
Consult the documentation for your particular compiler. Each will have
its own set of directives. For the GNU C++ compiler, assuming the code
is in a file named hello. cpp, the following may be entered at the command
line:
g++ hello. cpp
This will produce a file named a. out, or on Windows systems a. exe, that
can then be executed like any other program.
Here is the source for the Hello, world! program.
#include <iostream>
int main()
{
std: : cout << "Hello, world!" << std: : endl;
return 0;
}
Exercise 0-1
What does the following statement do?
3 + 4;