Home / C languaege / Some Basic Structure of C ++ Language

Some Basic Structure of C ++ Language

Here we will discuss Basic Structure  of C ++ Language  program for this let’s create a project am starting Code

Basic Structure of C ++ Language
Basic Structure of C ++ Language

Blocks you can use any IDE Microsoft Visual Studio ,Dev. C++or any other your Favorite IDE.

Procedure to type a program This Program Will Display a Hello World message on The Screen. Now Let’s Understand this Program Line by Line First of All.

Lets look at a very simple c++ program.

Header file Basic Structure  of C ++ Language



 Detail of Header file

 Here Hash Include is a preprocessors  directive. which tells the Compiler that we want to Include a header file in our program. Header Files are those files that comes with Compiler. Here we are including Iostream Header file. which is stands for Input Output Stream.

 we are including IO File. we are including this File because we want to work with Input Output Streams. Data in Computers travels from one place to another in form of Streams. If we want to display something on the screen we use output stream and in same way if we want to get input from keyboard.

 we use input stream Because we want to display Hello World message on the screen for that purpose. we are using court output Stream Objects that’s the reason we are including this upstream header file.

THE USING DIRECTIVE in Basic Structure  of C ++ Language

Using namespace std;

 After that we have using namespace. there we are telling that we are using standard  namespace is another concept. that we will cover in another time after that you were seeing a semi-colon in C++;


 we terminate every statement with semi-colon; After that this is a Main function whenever C++..

Then main function on C++

Always start with main()

program start’s it’s start execution from Main Functioning. the start this into stand for Integer this telling that Main function will return integer value after Completing its execution. we will talk about function in details later. These brackets indicating.

 that Here function is going to start and here it end’s.

Brace and function body{}

THE Body of function is surrounded by braces(sometimes called curly brackets).every function must use this pair of braces around the function body.

Program statements

Cout<<”HELLO WORLD”<<endl;

 count is a standard output object By using. this we can print anything on the screen these less than less than operator are called stream insertion.

 operators which are telling that we want to insert something into streams you will be watching Hello World in double quotations.

 marks in C++ we close every string with double quotations marks after that again less than less than sign which is a stream insertion operator after that we have end that is for ending a line

 it’s mean we want to go to next line on the Screens for that purpose we use end.

 after that because this is statement we terminate it with semi colon.

Return 0;

 return 0 here we are returning zero value of type integer Zero. normally indicate that our program exit after its successful execution.

 For example

 if we have some code over here And there come an error at run time means when running program program will terminate its execution by giving an error codes that will terminate its execution before reaching return 0so that code that will be return will greater than zero or less than zero that will indicate an errors that’s why at the end of program we return 0 so can determine that. our program has terminate  successfully without an error.

You may also like

C language Guide


 Now let’s run our program click on Build and run icon and watch that first Hello World message printed on the Screen then we go to next line and watch this zero this indicating that our program has run successfully without an error this indicating that how much time it takes to our program to complete its Works this program is executed in 0.025 seconds.




using namespace std;

int main()


Cout<<”HELLO WORLD”<<endl;

Return 0;


REVIEW about the Basic Structure  of C ++ Language

 let’s review it again hash include upstream here we are including input output stream header file using namespace std.

 here we are telling that we are using standard namespace and here main function starts.

 Here we are using cout to display message on the screen and then we go to next line by endl.

 if we don’t use this using namespace std line then we have to told each time by putting std in start of object by putting std. and scope resolution operator.: in front of cout and end l. which tells the compiler we want to use cout object from standard namespace same for endl we have to tell that we are using endl which is from standard namespace.

 And Now see our program has run as it run’s last times instead of writing std :: every time we write it at top at once so that’s an easy way and these space are used for the understanding of human. If we remove theme program will run successfully we can comment in C++. that compiler ignores its if we read next time our program or any other programmer read our program he/she can understand that what we are doing for single line comment we use slashes and here we can comment anything.

 For example

 for multi-line comment we put slashes and between them we put Asterisk between theme which indicate that we want to use multi-line.

Thank you            Allah Hafiz

The following two tabs change content below.
Hi I am Ch Shahbaz from Pakistan.I love to writing different type of informative Articles. By profession i am a Pro Blogger, Web Developer, Graphic Designer and Creative writer.

Latest posts by Ch Shahbaz (see all)

Check Also

Object Example

Basics OF C++ OBJECT Oriented Programming

What is meant by Object-Orientation? The technique which is used to imagine our programming complications. …


  1. please email me back on my email, i would like us to work together

  2. Thanks ch shahbaz for putting up such an outstanding and passionate information with us through this article. Your research and collection of information is really exceptional. The article covers full of great knowledge and well authored. Valuable sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *