How to write a Program in C++?

Syntax of basic C++ Programmimg:-

This is basic C++ Program.

In this Programming structure. We uses following syntax.

  • Header file :- The very first statement includes the header file. Header file is a library file, here iostream header file is a Input/output library file which provides “cin” and “cout” method for input and output.
  • Main function:- It is the main function of program. Program always starts from this function. Under { } is called body of the function, which always executes the first.
  • Cout :- This statement print “Hello C++ Programmer”on to the screen.


Compile and Execute C++ Program :-   

There are following steps

  • Open the C++ Editor.
  • Open New tab and select new file.
  • Type the Program above.
  • Save the file with “.cpp” extension.
  • Now open compile menu and click compile option for compiling the program. (For short cut use Alt + F9 key)
  • After successful compilation, For running the program Open run menu and click run option. (For short cut use Ctrl + F9 key)
  • For seeing the output screen Alt + F5 key is used.
  • Returning from Output to editor press Esc Key.

This is the screen short of the first Program with output.


Leave a Reply