Basic Structure Of C Program Concept 02


The format of writing a program is structure of c program. The basic structure of c language is flexible. It increase the power of the language. It consists of the following parts :-
  • Pre-Processor Directive 
  • Main function ()
  • Program body (c statements)
  • We can also write comment (/*   */)

  • Pre-Processor Directive 
Pre-Processor directive is an instruction given to the compiler before the execution of the actual program.It is also known as compiler directive. It is the part of C++ compiler. It modifies the program before compilation.
The pre-processor directive start with symbol # and the keyword include and define. It is not terminated with semicolon.
The include pre-processor directives enable a program to access a library. Each library contain header files. It is used to include header files in the program.

Syntax:-

#include<standard header file>

Example:-

#include<stdio.h>
#include<math.h>

The above statements tells preprocessor to include the file stdio.h and math.h.

The define directives is used to define a constants, it also start with # symbol.

Syntax:-

#define identifier value

Example:-

#define PI 3.141593

#                   indicates pre-processor directive
define           used to defined a constant
identifier      name of the constant
value            value associated with identifiers 

Header files are collection of standard library functions to perform different task. There are many different header files for different purposes.Each header files contain pre-defined function. The extension of header files is  .h .It is normally stored in INCLUDE sub-directory. The name of the header file must written in angle brackets <>.

Syntax:-

#include<header_file_name>
we can also write in double quotes like

#include"header_file_name"

Examples:-

#include<stdio.h>
#include<math.h>

The word std means standard and io mean input/output. Math.h is for predefined mathmatical expression.

Main Function()

The main() is used where the execution of C program starts. When the program is executed, the control enters the main() function and starts executing its statement.
Each program must contain main() function. If the program does not contain it will compiled but never execute it.

Any numbers of the statements can be written in main() functions. The body is enclosed in braces { }.

Syntax:-

void main()
{
body of the main function
}

You have successfully done this concept revise it at the next two days.

Any Question Contact Me Or Write in Comment

No comments:

Post a Comment