Basic Program Structure of C++.

Formate of writing a program is called its Structure.The Above picture show the formate of C++ program.
C++ structure is very powerful and easy to understand.
C++ Structure is consists of 3 parts.
  • Preprocessor Directive
  • Main() Function
  • Body of Program / body of main() function.

1-Preprocessor Directives.

   Preprocessor directives are the set of instruction given to the compiler before executing the program.
 It always start with the '#' symbol and always written at the start of the program.
             '#include' specify that this a preprocessor. 
             iostream is the name of standard library function / name of the file.
           '.h'  is the extension on that file.It specify that this is a header file.

  Following are some commonly using Header Files.
  • #include<iostream>
  • #include<conio.h>
  • #include<math.h>
iostream stands for 'input-output stream'.
conio    stands for   'console input-output'.
math.h    is used to include predefine functions of math.

2-Main() Function.

Main Function is the starting point of a program.Every program must contain a main function,if any program does not contain main() function it can be compiled but can not be executed.All the statements of program can be written in main function.

3-Body of C++ Program.

Body of the program contain statements.These statements written in the curly braces.Braces also known as delimiters.So these statements are the instruction that we give the computer to perform any task.
Computer execute all these statements one by one in sequence.

Program to print 'C++ Programmer' on the Screen by using 'cout'.

void main()
  cout<<"C++ Programmer";

What is 'cout'.

cout object is used to print a message on the screen,it always start with the insertion operators'<<'
and the message is written between the double quotation marks.(" ") and statement is terminated with semi colon ( ; ).

Topics you can find here;
  • c++ development 
  • how to code in c    
  • computer programming
  • c++ programs examples
  • c++ programs pdf
  • c++ programs with output
  • c++ programs for beginners   
  • c++ programs list

Basic Program Structure of C++. Basic Program Structure of C++. Reviewed by Shoaib Jameel on 21:04 Rating: 5

No comments:

Powered by Blogger.