Introduction: Hello World Program in C++
I am new to Instructables please support me. Sorry that i uploaded hello world first and didn't give an intro to c++. My second instructable would be about the introduction to c++. Please favorite me and comment. Any queries submit in the comments.
Step 1: Materials You Need
1) C++ ide (integrated development environment) .
I am using Visual studio community 2015,
you can also use Codeblocks or Dev C++.
2) Basic C++ knowledge i.e. cout , header files , what is ' using namespace std; ' . Don't worry i will explain it to you in my next instructable
3) Interest in C++ programming .
Step 2: How to Start
First click on the ' New Project ' Button.
Many options will appear asking what type of application you want ,
select ' Console Application '.
Now in the writing space copy the following code :-
using namespace std;
getch(); ( _getch(); if using Visual Studio 2015 )
Step 3: Compiling and Running the Program
1) You will have to first debug the program
In computers, debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code or the engineering of a hardware device. To debug a program hardware device is to start with a problem, isolate the source of the problem, and then fix it. A user of a program that does not know how to fix the problem may learn enough about the problem to be able to avoid it until it is permanently fixed.
Click on the debug icon.
2) Now locate a build and run icon in your ide and click on it.It would open a command prompt screen displaying the output of your code.
Step 4: Basic Explanation of the Program
1)Header files (iostream , conio.h)
These are files that include various function such as iostream includes cout , cin and conio.h includes getch().
They tell the compiler as to what it has to do i.e., what function will the compiler perform.
2)Why to use ' using namespace std '
A symbol may be for instance a function, class or a variable. E.g. if you add using namespace std; you can write just cout instead of std::cout when calling the operator cout defined in the namespace std . "using namespace" is a command, and "std" is a little something called a library. "std" stands for "standard".
3) What is the use of cout and getch()
Standard output (cout) On most program environments, the standard output by default is the screen, and the C++ stream object defined to access it is cout .
The getch() function is used to catch a character from the keyboard. The getch() function reads a single character from the keyboard but does not show on the screen. For this functionality, you can use the getch() function to hold the output window until hitting any key from the keyboard.
4)What is return 0;
In C++ programs the main function is of type int and therefore it should returnan integer value. The return value of the main function is considered the "Exit Status" of the application. On most operating systems returning 0 is a success status like saying "The program worked fine".
PLEASE VISIT MY TUTORIALS ON C++: introduction to c++
We have a be nice policy.
Please be positive and constructive.