History of C:
. C is a programming language developed by Dennis Ritchie in 1972 in USA.. It was mainly developed as a system programming language to develop operating system Unix.
. C language was evolved from ALGOL, BCPL, B.
. First book of C programming was published as K&R C by Brian Kernighan and Dennis Ritchie in 1978.
. First standard of C was developed by American National Standards Institute (ANSI) as ANSI C in 1983.
. ISO (International Organization for Standardization) approved ANSI C in 1990.
. Later on Standard of C is released by improving its features as C 99 in 1999.
. Current Standard of C is C 11 developed in 2011.
Features of C:
. C is widely used in Computer technology.. It is inspiration for the development of other languages.
. Following are the features of C language:
. Simple: C program is very simple to understand which uses English language.
. Portable: C programs can run on other machines with less or no modifications.
. Powerful: C provides variety of data types, functions, control statements.
. Fast and Efficient: Programs written in C are very much fast and efficient compared to BASIC languages.
. Structure Oriented: It aims clarity of the program. Maintains a proper structure and reduces the complexity.
. Modularity: C program can be divided into subprograms or modules which are integrated together to form complete program.
. Pointers: Pointers has direct access to memory which improves performance. C supports pointers.
. Extendable: C programs are extendable.
Applications of C:
. Operating System development.
. Database Systems.
. Device drivers.
. Text Editors.
. Embedded Systems.
. Language Compilers and Interpreters.
. Assemblers.
Structure of a C program:
. Documentation section: It consists of set of comment lines which contains name of the author, program details etc.
. Link section: It provides instructions to compiler to link functions from system library using #include directive.
. Definition section: It defines all symbolic constants used in the program using #define directive.
. Global declaration section: Variables which are used in more than one function are called global variables, these are declared in this section.
. main() Funtion section: Every C program must have this section. It includes 2 parts enclosed in curly braces:
Declaration part: Declares all variables used in the executable part.
Executable part: It contains logic of the program to be executed.
. Sub-program section: If the program is multi-functioned program, sub-program section contains all user-defined functions called by main() function.
. Link section: It provides instructions to compiler to link functions from system library using #include directive.
. Definition section: It defines all symbolic constants used in the program using #define directive.
. Global declaration section: Variables which are used in more than one function are called global variables, these are declared in this section.
. main() Funtion section: Every C program must have this section. It includes 2 parts enclosed in curly braces:
Declaration part: Declares all variables used in the executable part.
Executable part: It contains logic of the program to be executed.
. Sub-program section: If the program is multi-functioned program, sub-program section contains all user-defined functions called by main() function.
Running First C program:
. Open the DOS Box.
. Write the program:
/*This is First Program:Hello World*/ ------------------Documentation section
#include<stdio.h>
#include<conio.h> --------------------------------------Link Section
void main()-----------------------------------------------main() Function section
{
clrscr();
printf("\n Hello World, this is my first program");------Executable part
}
. Save the file as HelloC.c by pressing F2 key.
. Write the program:
/*This is First Program:Hello World*/ ------------------Documentation section
#include<stdio.h>
#include<conio.h> --------------------------------------Link Section
void main()-----------------------------------------------main() Function section
{
clrscr();
printf("\n Hello World, this is my first program");------Executable part
}
. Save the file as HelloC.c by pressing F2 key.
. Compile the program by pressing Alt+F9 key.
. To view the output, press Ctrl+F9 key.