Before delving into the basics of C++ programming, it is essential to understand the process of creating, compiling, and executing your initial C++ program.
To start creating your initial C++ program, launch the C++ console and input the subsequent code:
#include <iostream.h>
#include<conio.h>
void main() {
clrscr();
cout << "Welcome to C++ Programming.";
getch();
}
include directive includes the standard library functions for input and output operations. It offers the cin and cout streams for input and output handling correspondingly.
include directive imports the standard input output library functions. The getch function is declared within the conio.h header file.
In C++ language, the main function serves as the starting point for all programs. The presence of the void keyword indicates that this function does not return any value.
Printing the message "Welcome to C++ Programming." on the console is achieved by using the code snippet cout << "Welcome to C++ Programming.".
Invoking the getch function prompts for input of a singular character, effectively pausing the screen until a key is pressed.
How to compile and run the C++ program
There are two methods to compile and execute the C++ program: through the menu option or using a keyboard shortcut.
By menu
Now, proceed to select the compile option from the menu and then choose the compile submenu to compile the C++ program.
Next, select the "Run" option from the menu, followed by choosing the "Run" submenu to execute the C++ program.
By shortcut
Alternatively, you can compile and execute the program directly by pressing the ctrl+f9 keys.
You will see the following output on user screen.
You have the ability to access the user interface at any moment by pressing the alt+f5 keyboard shortcuts.
Now press Esc to return to the turbo c++ console.