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:
Pages: 1 2