C++ tutorial-basic syntax

C++ Basic Syntax

In the previous post, you learned to create simple Hello World program in C++ by using Notepad or Dev-C++ editor. This tutorial teaches you the basic syntax of C++ programming language that you should know since you are new to this computer programming language.

- #include<iostream>
It is a statement written down to include iostream header file that will allow us to use the command to receive input from users and display text on the screen.

- using namespace std;
The statement will import std namespace and allow us to use commands without having to type out their full names.
A namespace defines names of variables or functions so that they do not conflict with other variables or functions that have the same names.

- C++ program will start from the main method:
int main()


-return 0;
This statement will tell the C++ compiler that your program ends here without any error.
A value other than zero will be treated as abnormal termination by the operationg system.

-cout followed by <<

 It is used to print text on the screen.


lakshmi comment


Can you amplify "the using namespace std "?

Troy comment


for more C++, C exercises,
please visit http://ccphplusplus.blogspot.com/


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.