3. Integrated Development Environment
Typing in a Program
Before you start to type in programs, we recommend disabling one of the more intrusive features of the editor in Visual Studio 201x. In the menu, select TOOLS -> Options. Options dialogue will open. Under Text Editor -> C/C++ -> Tabs, select Block instead of Smart indenting. Under Text Editor -> C/C++ -> Formatting -> General, uncheck the first three checkboxes, and for the When I paste option select Do nothing. Then click on OK button.
With that out of the way, type in the following program:
#include <iostream> using namespace std; int main() { cout << "I sing" << endl; for (double i=1; i<=3; i++) { cout << "Sail sail" << endl; cout << "my little boat" << endl; } cout << "While I catch my fish" << endl; }
Notice we have added the two lines of code at the beginning of the program. Their purpose is a more advanced topic which we will come back to in more detail later, but in Chapter 2 we promised you an explanation, so, let us say that without those two lines, we would be unable to utilize the words cout
and endl
. 'iostream'
is the name of one of the libraries built into C++, and its name is a
shortened form of 'input-output stream'. The next line, 'using namespace std;'
allows us to use the names from the mentioned library without the std
prefix;
otherwise, we would have to write std::cout
and std::endl
.