How to Create “Hello World” C++ Program in Windows Using Microsoft Visual Studio

For the beginners of programmer, the first program is always start with “Hello World” program. Actually, the aim of this program is to make understand / learn the C++ beginners about the basic structure of C++ which can just simply print a text. C++ program can be done using the simple notepad to many other IDE. In this tutorial, you will learn how to create a C++ program, “Hello World” program using Microsoft Visual Studio. I use Microsoft Visual Studio 2010 Ultimate to write the tutorial of Hello World C++ program in Windows environment (my operating system is Windows 7, however you can do the same thing to other version of Windows operating system).


How to Create “Hello World” C++ Program in Windows Using Microsoft Visual Studio


Follow the simple step by step to create the “Hello World” C++ program in Microsoft Operating system using Microsoft Visual Studio 2010 Ultimate.

Step 1: You must have to start Microsoft Visual Studio 2010 Ultimate or  Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. When Microsoft Visual Studio has started, click on File menu, point to New, and then click Project.

Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

Step 2: After step 1, New Project window will be appeared and from Project Types, click Visual C++ [Visual Studio 2005, you have to click Visual C++ under Project Types]. Later under Templates, click Win32 Project and put the name of the project. For example, we type MyTestProject for our C++ project. Moreover, you may put the Location text box, to save the project to the desired space of your computer hard disk and finally click on OK button.

2_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

Step 3: When you have finished the step 2, you will find the Win32 Application Wizard - FirstApplication dialog box. From the Win32 Application Wizard dialog box, click Application Settings in the left pane and you will see the Application type. Under Application Type, choose Console application by simply clicking Console application. Now, under Additional options, click to select the Empty project check box and lastly click on Finish button to move forward.

3_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

Step 4: After completing step 3, Solution Explorer will be appeared on Microsoft Visual Studio. From Solution Explorer, just right-click on Source Files folder and choose Add and then click Add New Item.

4_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

Step 5: You now have to add your program. Click on C++ File (.cpp) under Templates and write the name of the program in the Name text box with .cpp extension. For example, we type HelloWorld.cpp for our program. At last, click Add button to complete the creation of .cpp file.

5_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

Step 6: Now, we have to type the code of our Hello World program. Just type the following lines of code.

#include<iostream>

using namespace std;

int main(){
   
    cout << "Hello World...";
    cout << endl;
}

6_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

Step 7: When you finished the coding of your first C++ program (“Hello World” program), you need to build it before running it. Click on Build menu, and then click Build Solution. If everything is ok the you will find a successful message that your program is build successfully. Otherwise, you will get error message. Then you need to correct the codes.

7_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio 

Step 8: When the build process of your first C++ program is successful, then press CTRL+F5 keys together to run the application which you just have created. You will find the the following message in a Command Prompt window:

Hello World…
Press any key to continue…

8_Create “Hello World” C   Program in Windows Using Microsoft Visual Studio

And that’s all. Following the above steps you can easily create your first application i.e. your first C++ program (“Hello World” program) using Microsoft Visual Studio on your Windows computer. Hopefully, you are able to do it successfully. However, if you have any problem doing this program or to understand this tutorial, please mention this in the comment section. Don’t forget your own opinion regarding this tutorial.

@ Written by hideMyTips

No comments:

Post a Comment