Structure of C++ programs info

Asked By 20 points N/A Posted on -
qa-featured

A C++ program consists of three main parts name them?

Explain Preprocessor Directives

The main () function

and C++ Statements?

SHARE
Best Answer by morkel.m
Answered By 0 points N/A #114143

Structure of C++ programs info

qa-featured
  • Preprocessor is a collection of special statements (program), called "Directives" which are executed before the compilation process. Whenever a C++ program is compiled, the preprocessor first examines and scans it for compilation. The second main thing that a preprocessor does is to process all the preprocessor directives. All lines that begin with a "hash(#)" character are preprocessor directives.
  • for example:
  • #include<iostream.h>
  •  All C++ programs are composed of different units or functions, in which main() is one of them, which must be present in every C++ program. It is the main() function which is called by the operating system when name of the program is typed at the OS prompt. Since normally no arguments are passed to main() and main() does not return a value, it frequently looks like this
  • "void main(void)".
  • "void" means no data type at all. It is generally used with functions that return no values. Empty parenthesis are usually used to indicate a void parameter list, which means the same thing as "void". So "main()" is equivalent to "void main(void)".
  •  All functions are consist of two parts,
  • 1. Function header
  • 2. Function body
  • Function header consists of the type and the name of the function. Every function in a program must have a unique name in the program with a set of parenthesis immediately following it. This set of parenthesis helps to distinguish functions from variables. For example
  • void AVERAGE()    int FACTORIAL()     void REPORT()
  • These three are the examples of function headers.
  • The function body or function block consist of the C++ statements that the function performs. C++ statements are free format, they may appear anywhere on a line. The compiler does not care. It only needs blanks to separate symbols and semicolons to separate statements. These statements must be enclosed within a pair of braces.
  • # include<headername.h>
  • void main()
  • {
  • statement1;
  • statement2;
  • }
Best Answer
Best Answer
Answered By 0 points N/A #114144

Structure of C++ programs info

qa-featured

Hi,

  • C++ program consists of functions ,variables ,objects.
  • Preprocessor directives : These lines are always preceded by #symbol .The lines which are included in the programming are known as preprocessor directives .Examples are #define and #ifdef .
  • The main() function is the starting line of the program it is the point where all the c++ programs start .The instructions which are contained within the main function will be the first one to be executed.
  • C++ statements :  The C++ statements are 
  • Expression statements
  • Null statements
  • Compound statements
  • Jump statements
  • iteration statements
  • Declaration statements

Related Questions