Make your own free website on Tripod.com

Lesson 1:- Introduction To C.

Prev || Home || Next

Bar_line.gif (11170 bytes)

                C was developed by Deneis Ritchie at Bell Laboratries in 1972. It is a robust language whose rich set of built in functions and operations can be used to write any complex program. For many years C was mainly used in academic environment. But with the increasing popularity of unix, now a days it has begun to gain widespread support among computer professionals. Today C is running under a number of operating systems.

                C compiler is well suited for writing both system software and business packages. Programs written in C are efficient and fast. This is due to its variety of data types & powewful operators. Moreover C is highly portable. This means C programs written for one computer can be run on another with little or no modifications. C language is well suitable for structured programming thus requiring the user to think of a problem in terms of a function, modules or blocks. Another important feature of C is its ability to extend itself. A C program is basically a collection of functions that are supported by C library.

Sample C program:-

main()

{

    clrscr(); /* To clear the screen of DOS Shell to see output neatly */

     /*  Printing on the screen begins */

    printf("Hello! How are You?");

    /* Printing ends */

    getche(); /* To echo the screen since the DOS Shell screen is not echoed at normal */

}

 

               The main() is a special function used by the C system to tell the computer where the program starts. Every program must have one main() function. The opening brace('{') indicates the start of function main() and closing brace('}') indicates end of main() function.

                The lines begining with /* and ending with */ are known as comment lines. Commnt lines are non-executable and non-compiled code statements. They are for the convenience of the programmer.

                "printf" is a predefined standard C function for printing or displaying the output on the screen. Predefined means that it is a function that already been written and compiled and linked together with our program at the time of development. Every statement in C should end with a semicolon(;)mark.

                C program may contain one or more sections. Documentation section gives name to the program. Link section provides instructions to the compiler. Defination section defines all the symbolic constants. Variables used in one or more functions are called global variables therefore they are declared in the global declaration section. Declaration part declares all variables used in the executable part. There should be at least one statement in the executable part. The subprogram section contains all user defined functions called in main() function. All sections except the main() function section may be absent when they are not required.

 

Execution of C program:-

1) Creating the program: Load a editor and write down a code, save it with the extension .c (eg. abc.c).

2) Compiling the program: A here translation of source code is done after debugging,called as a object code.(eg.abc.obj)

3) Linking the program: Process of putting together other program files & functions required by the program.(eg.abc.exe)

4) Executing the program: Here program is executed. Press Alt+F9 to compile and Ctrl+F9 to run the program.

Bar_line.gif (11170 bytes)

Prev || Home || Next