Write the Program Visual C++

Posted by Didi Setyapramana On 10:24 AM 0 komentar

Type the source code for your program into the blank editing pane located in the right side of the window. Figure 9 contains the source code for a simple C++ console program that displays the phrase, “Hello World.”
Note that the C++ editor automatically selects different colors for C++ reserved words and provides automatic indentation for blocks of code.


 



Figure 9 Hello World Source Code File


Compile and Build the Program


Before you can execute the program you have written, you must save it and compile it. To save the file, either click in the edit window to make it the active object or click on the hello1.cpp filename in the Solution Explorer, then select Save hello1.cpp from the File menu. You could also click the Save or Save All icon in the toolbar, or press CTRL+S.
Once the program is saved, you compile it by selecting the Build Solution option from the Build menu. This will cause Visual Studio to both compile and link you program. Once the program compiles and links, the results will be shown in the Output window at the bottom. (See Figure 10.) In this example, the program compiled with no errors and no warnings.






Figure 10 Results of Compiling the Program

After the build process has successfully completed, you can now execute the program by selecting Start Without Debugging from the Debug menu. (See Figure 11)



Figure 11


Figure 11 Initiating Program Execution
The program results will appear in a new DOS window. Notice that the phrase “Press any key to continue” has been added to the program output. This additional code was added to keep the DOS window open until you have had a chance to view the output and press a key on the keyboard. (See Figure 12.) Once a key on the keyboard is pressed, the program stops execution and the DOS window closes. This output phrase is not actually included in your program, as you would see if you opened a DOS window and executed the program directly



Figure 12 Program Results

0 Response for the "Write the Program Visual C++"

Post a Comment