Basic Structure of C Program



A Brief History of C Language

 

BASIC STRUCTURE OF C PROGRAM:

  • Writing style of a program is called Structure of program.
  • C Program has 3 main parts
  • Processor Directives
  • The Main( ) Function
  • C Statements

Example:

# include <stdio.h>Processor
Directive
main( )Header
{File
printf (“First Program”);Main Function
C Statement
getche( );
}

 

Processors Directives:

  • Instructions given to Compiler before actual program are called Processor Directives.
  • It does some processing before the Compilation process starts.
  • Processor Directives are used to include Header files in the program. (e.g.)
#include <Stdio.h>or#include “Stdio.h”
or #define <Stdio.h>or#define “Stdio.h”

 Header Files:

  • Contain Definitions of standard library function.
  • C has many header files.
  • Each header file contains definitions of one type of functions only.
  • (e.g.) math.h (Has Mathematical Function only)
  • Header File has an extension .h
  • The name of header file is written in angle brackets < > or double quotes “ ”after #include or #Define directive.

Main Function:

  • C Program begins with “main( )” function.
  • “main( )” must be included in every C Program.
  • Execution will Starts through “main( )” Function.
  • If there in no “main ( )” Function, Compiler generated an error. (e.g.)

main(  )

{

Program Statements…

}

C   Statements:

  • Statements are written between Curly braces { } of main function.
  • Each statement of C ends with Semicolon ( ; ).
  • Mostly written in lowercase, but in some cases, can also be written in uppercase.

CREATING, EDITING AND SAVING A PROGRAM:

  • Creating is the process of writing program into C compiler editor.
  • Editing is the process of make changes into written program (Del and Backspace key is used to delete characters).
  • After creation of program save it as file name.c.

COMPILING, LINKING AND EXECUTING A PROGRAM:

About Saweel Ur Raheem

Check Also

MCSE Notes Lecture # 4 : Applying Security to Folders

LECTURE 4 APPLYING SECURITY ON FOLDERS: Open Folder Options. Go to View Tag and uncheck ...

© Copyrights 2014. All rights are reserved www.latestcontents.com