Smile

Sunday, May 29, 2011

Structure of C program


Document Section

This section is used to write comment lines for describing program or part of the program. This section will not be executed. This is an optional section.
Example
//Program for finding prime numbers from 1 to 100
/*Program for finding number is even or odd*/

Pre-Processor Section or Link Section

This section is used to include predefined or user-defined header files to the present program.
Example
#include<stdio.h>

Global Declaration Section
This section is used to declare the global data (which can be used through out the program). This is also an optional section.

Main programming section
This section is the heart of C program. With out this section the program will not run.

SubProgramming Section
This section is used to represent the user defined functions which will be explained later.

Tuesday, May 17, 2011

Block Diagram of Execution of ‘C’ program


























The compilation and execution process of C can be divided in to multiple steps:
  • Preprocessing - Using a Preprocessor program to convert C source code in expanded source code. "#includes" and "#defines" statements will be processed and replaced actually source codes in this step.
  • Compilation - Using a Compiler program to convert C expanded source to assembly source code.
  • Assembly - Using a Assembler program to convert assembly source code to object code.
  • Linking - Using a Linker program to convert object code to executable code. Multiple units of object codes are linked to together in this step.
  • Loading - Using a Loader program to load the executable code into CPU for execution.