A C ++ program consists of one or more text files saved with the .cpp extension.
For all of the following examples, we will work with the Codeblocks program, which is free and offers all the C ++ programming features (edits the source code, compiles, and runs the program).
After downloading and installing the program, its interface shows that in the figure below:
After writing the program, we will save it as hello.cpp, then compile it using the Build menu, followed by Compile current file. After compilation will result the hello.o file. If our program also contains the main function, the executable file will result: hello.exe.
To run our program, we use the Build menu, followed by Run.
Following the execution of the program, the result will appear in the console as follows:
Now let's talk about the program.
When program compile begins, preprocessor C is called to handle the preprocessor directives found in the source code. The preprocessor directives start with #. For example, the directive:
means the inclusion of the header file required for read and write operations.
Then follows the main function, with which the program starts.
The following instruction is a statement. The statements are executed in order of their appearance. Our statement:
std::cout << "Hello!";
specify that the standard output (std :: cout) will be used, which is usually the computer screen, then the characters << indicates that something will be inserted and then follows the "Hello" text that will be inserted. The statements end with the character;. Next, the instructions:
which indicates the end of life of variables of the main () function, means the end of the process.
Visit my websites:https://www.jwebsaints.com