Saturday 7 March 2015

how to Write first program in C++

 Writing first C++ program part 1    There are three steps in which you can write your first C++ program. Step 1  In... thumbnail 1 summary

 Writing first C++ program part 1 

 

There are three steps in which you can write your first C++ program.
Step 1 

Including library In first step we include library in C++ program.
Syntax
#include<iostream.h>
Step 2 

Declaring main function
In Second step we define main function of our program .The role of main function in C++ program is like head in human body and every C++ program will have one main function must.
Syntax
int main()
{
};
Declaring main function in C++ is very easy just simply write int main () and put the Curly bracket {} and write your code inside these curly barked but it is your first program So keep the curly barked empty in this case. Note after the end of every line of main function in C ++ you will put semi colon must.
Step 3 

System pause and Ending program
To display final result on the screen in C++ program we use system ("pause");
Syntax
system("pause");
It will pause the system until a user press a key.
To end program in C++ just simply write return 0.
Syntax
return 0;
It will end your program. It is all about writing first program in C++after doing these steps Save, Compile and Run your program.

Example
#include<iostream.h>
int main()
{
system("pause");
return 0;
};