C PROGRAMMING , STRUCTURE OF C PROGRAMMING

     

                    C PROGRAMMING 

The c language was developed in 1970's at Bell laboratories by Dennis Ritchie . Initially it was designed for programming in the operating system called UNIX. After the advent of c,the whole UNIX operating system was rewritten using it .

C PROGRAMMING is a structure high level language that follows procedural approach for designing the program 

History of development of c programming


The c language is derived from the b language, which was written by Ken Thompson at at&t Bell laboratories.the b language was adopted from a language called BCPL(basic combined programming language), which was developed by Martin Richards at Cambridge University.In 1982 a committee was formed by ANSI (American National standards institute) to standardized the c language. Finally in 1989 the standard for c language was introduced known as ANSI C.

Structure of C PROGRAMMING

C is a structured programming language that is divided into several sections and each section has some specific task.

C program is divided into following sections
  1. Documentation section
  2. Link section
  3. Definition section
  4. Global declaration section
  5. main() function section
     6. { Declaration part 
             Executable part }

      7. Subprogram section
       { User defined function }

1.       Documentation section 

In this section, we write comments related to the program to tell what is the program has been created and what are the speciality of the program

2.        Link section 


The link section provides instructions to compiler to link function (header file) from the system library
Such as using the  #include directive

Example:-    #include<stdio.h>


3.       Definition section


it is defficult to write a constant several time in program.
If we want to use a constant several times then we provide it a name and  use this name instead of writing a constant value everywhere these type of constant are called symbolic constant or named constant. the definition section define all the symbolic constant such using the

#Define directive
Example:-  #Define pi 3.1476

Note :- 
1. define section not a statement so semicolon at end is not needed

2. We also can define library function name like printf,scanf to another name 
Example:- #define show printf

3. Keywords will not be defined to another name using #define

4.      Global declaration section

There are some variable that are used in more than one function such as variables are called global variables and are declared in global declaration section that is outside of all the functions.
This section also declares all the user defined function.

5.        main() function section


C program is a collection of one or more function every function is a collection of statement and perform some specific task
One function can be nested in in other functions
Every other functions ( pre defined or use defined) called in main() function.
main() is the first function of every c program that is responsible for starting the execution and termination of the program.
main function is the special function that always starts executing code .
from the  main() having 'int' or void as return data type


main() having two parts :

{  Declaration part
    Executable part  }

'{' :- The programming cod is  executed inside it

                      Declaration part 

In declaration parts declares all the variables used in the executable part

                        Executable part

This part contains all statements that are be executed by compiler.the program execution begins at the opening and closing brace .all statements in thr declaration and executable part end with a semicolon.

6.         Subprogram section


Sub program section contains all the use defined function that called in the main function 

Comments