A simple c++ program

using namespace std;
int main()
cout<<"Welcome to c++ program"<<endl ;
return 0;
Output of above Program
Output of above Program

Output: Welcome to C++ Program

  • Explanation of above program:-
  • Every c++ program contains a main function.
  • The iostream is header file which contains all types of libraries.
  • The meaning of “cout” is print the output on the console. cout is similar as printf in c language.
  • namespace is a declarative region that provides a scope to the identifiers( the name of function ,variable etc.) inside it.
  • Namespace is used to organize code into logical groups and to prevent name collision that can occur especially when the code base. include multiple libraries.
  • The meaning of std is standard which contains the definition of cout , cin, etc.
  • endl is similar to \n which used to take new line.
  • There are minor difference between endl and \n is that endl doesn’t take any space in memory but \n take space in memory.
  • The return type of main function is int so this function return something like return 0 .
  • We must need to use terminator in c++ as similar to c-language.


Comments is none executable lines of code which is used to explanation of source code of any program.

Why comments are important in any program or in software

Comments increase code readability for the same or different developer of that source code.

The another use of comments is when any programmer doesn’t complete the program or software and left that organization then new programmer understand the previous programmer’s code with the help of comments

Comments is also helpful in debugging time.

There are two way to comment in C++.
1.single line comment.
2. multiline comment.
  • single line comment:- Double forward slash used for single line comment. Example :– sum=a+b; // sum of two integer.
  • Multiline comment:– When the size of comments grow in more than one line then we need to use multiline comments.
  • Example :– /*comments in multiline */

Related Links :

Leave a Comment

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