Overview of C by maryjibi

VIEWS: 6 PAGES: 13

									Overview of C
C is…
   Structured.
   High-level.
   Machine independent.
   Platform independent.
   Used by software developers to develop
    programs.
History

   C was evolved from ALGOL,BCPL and B
    by Dennis Ritchie at Bell laboratories.
   UNIX operating system was coded
    entirely in C.
   American National Standards
    Association (ANSI) defined a standard
    for C which is known as ANSI C.
Importance of C.
   C has a rich set of built-in functions and
    operators to write complex programs.
   Programs in C are efficient , fast and
    robust.
   C is highly portable.
   C is structured.
   C can extend itself.
Basic structure of a C program.
    Documentation section
    Link section.
    Definition section.
    Global declaration section.
    main()
     {
     }
    Sub program section.
       Function 1.
       Function 2.
       ….
Programming style.
   C is a free-form language.
   Ie, we can begin typing anywhere in
    the editor.
   The advantage is to develop a readable
    program.
   Programs are developed in lowercase.
    Upper case is used only for symbolic
    constants
   C is case sensitive.
Executing a C program.
1.   Creating the program.
2.   Compiling.
3.   Linking with functions needed from
     the C library.
4.   Executing the program.
Process of compiling and running.
            Source program


               compile



                Syntax          yes
                 errors
                          no

            Link with library

                     Executable object code
                Execute

                output
A simple program.
main() function
   Tell the compiler where the program starts.
   C programs have only one main().
   Empty pair of parenthesis indicates no
    arguments.
   Main() has ‘{‘ to indicate the beginning of the
    function and ‘}‘ to indicate the ending of the
    function. Statements between these two
    braces form function body.
     Forms of main() function
   main()        indicates no arguments.
   int main()   returns an integer value to OS.
   void main() doesn’t return anything to OS.
   main(void) indicates no arguments.
   void main(void)
   int main(void)
Comment Lines.
   Begins with /* and ends with */
   Enhance readability and understanding.
   Not executable statements.
   They are ignored by the compiler.
   They cannot be nested.
   Comments do not affect the execution
    speed size of a compiled program.
The #include directives
   Some functions stored in the C library.
   These library functions are grouped and
    stored in files known as header files.
   To access these functions we use
    preprocessor directive #include.
             #include <file name>
    Here file name is name of the library file.
   Preprocessor directives are placed at the
    beginning of the program.
   Examples are:: #include<stdio.h>,
    #include<conio.h>,#include<math.h>

								
To top