SlideShare a Scribd company logo
2
Most read
7
Most read
9
Most read
Introduction to C Language
                            C Tokens
              Structure of C Program
Compiling and Executing a C Program




           C Language Preliminaries

                         Abhineet Anand

             Computer Science and Engg. Department
       University of Petrolium and Energy Studies, Dehradun


                       November 19, 2012




                    Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                               Introduction
                                    C Tokens
                                               History of C
                      Structure of C Program
                                               Characteristics of C
        Compiling and Executing a C Program


Introduction


      C is a high level language.
      It also has the capability of low level programming. So,
      sometimes also referred as middle level Programming
      Language.
      Best Programming Language for learning procedural
      programming approach.
      It was developed at the Bell Laboratory, USA (now AT & T),
      in 1972.
      It is the outcome of Dennis Ritchie and Brian Kernighan.



                            Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                               Introduction
                                    C Tokens
                                               History of C
                      Structure of C Program
                                               Characteristics of C
        Compiling and Executing a C Program


History of C

     C is derived from two early programming languages such
     as BCPL (Basic Combined Programming Language) and B
     language developed by Ken Thompson.
     In 1972 Dennis Ritchie developed a new version of B and
     named it as C.
     In 1978, Dennis Ritchie and Brian Kernighan jointly
     published a detailed description of the C language
     document. It is Known as K & R C.
     Some of Shortcomings of K & R C implementation are
     overcome by ANSI (American National Standard Institute)
     standards.


                            Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                                Introduction
                                     C Tokens
                                                History of C
                       Structure of C Program
                                                Characteristics of C
         Compiling and Executing a C Program


Characteristics of C

      C is a general purpose & structured programming
      language, which helps in development of system software.
      It has rich set of operators.
      It provides compact representation for expression.
      It allows manipulation of internal processor registers.
      Portability: any C program can be run in different machine
      with no modification.
      Rich set of data types and less number of reserved words.
      Pointer arithmetic and manipulation.
      Ability to extend itself by adding fuctions to its library.


                             Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                   C Tokens   C Tokens
                     Structure of C Program   Keywords and Identifiers
       Compiling and Executing a C Program


C Tokens

     The Basic and Smallest units of any programming
     language is known as tokens. When a complier complies a
     program, it recognises those basic units.
     There are six types of tokens in C. They are:
           Keywords
           Identifiers
           Constants
           Strings
           Operators
           Special Symbols.
     Each of these tokens is formed with one or more
     charecters of C language.


                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                   C Tokens   C Tokens
                     Structure of C Program   Keywords and Identifiers
       Compiling and Executing a C Program


Keywords


    Every word in C program is either a keyword or an identifer.
    All Keywords must be written in lowercase letters.
    C is case sensitive language.
    Keywords supported by ANSI C are:
    auto, break, case, char, const, continue, default, do,
    double, else, enum, extern, float, for, goto, if, int, long,
    register, short, signed, sizeof, static, struct, switch, typedef,
    union, unsigned, void, volatile & while.




                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                    C Tokens   C Tokens
                      Structure of C Program   Keywords and Identifiers
        Compiling and Executing a C Program


Identifiers


      Identifiers are the names given to program elements such
      as variables, arrays and fuctions.
      These are sequence of alphabets and digits.
      Rules for forming identifers names:
          First charecter must be an alphabet or an underscore.
          No special Charecter or punctuation symbols are allowed
          except the underscore "_".
          No two successive underscore are allowed.
          Keywords should not be used as identifiers.




                            Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                               Structure of C Program
                                    C Tokens
                                               Preprocessor Statements
                      Structure of C Program
                                               Declarations
        Compiling and Executing a C Program


Structure of C Program



  preprocessor statement
  global decleration;
  main( )
  {
  decleration;
  statement;
  }
  user defined function




                            Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                              Structure of C Program
                                   C Tokens
                                              Preprocessor Statements
                     Structure of C Program
                                              Declarations
       Compiling and Executing a C Program


Preprocessor Statements



     Begin with # symbol, also called the preprocessor
     directives.
     Direct the C preprocessor to include header files and also
     symbolic constants into C program. Few Statements :
         # include < stdio.h > : for standard input/output functions.
         # include "Test.h" : for file inclusion of the header files.
         # deifne NULL 0 : for defining symbolic constant, NULL=0




                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                              Structure of C Program
                                   C Tokens
                                              Preprocessor Statements
                     Structure of C Program
                                              Declarations
       Compiling and Executing a C Program


Global Declarations




     Variable or function whose existance is known in main( )
     function and other user defined function, are called the
     global variable.
     Its decleartion is known as global declarations.
     Excuation of C program starts with main( ).




                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                              Structure of C Program
                                   C Tokens
                                              Preprocessor Statements
                     Structure of C Program
                                              Declarations
       Compiling and Executing a C Program


Declarations


     Variable Decleration: All Variables, array, function used in
     C program are decleared and may be initialized with their
     basic data types.
     Statements: the instruction to the computer to perform
     some specific task. They may be:
         Arithmetic Statements.
         Input/output Statements.
         Control Statements.
         Other Statements.
     Comments: explantory notes on some instruction, which
     are not executed and enclosed with in /* & */.


                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                               Compiling and Executing a C Program
                                    C Tokens
                                               Standard Procedure
                      Structure of C Program
                                               Selecting OS
        Compiling and Executing a C Program


Compiling and Executing a C Program


     Compiling a C program means translating it into machine
     language.C Compiler does that for C pragrams.
     Various tools are availble which gives the facility of writing,
     editing, debugging and excuting C language program.
     This type of environment is known as Inetegrated
     Development Environment (IDE).
     Examples : Turbo C, Borland C/C++, ANSI C and many
     more.




                            Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                                Compiling and Executing a C Program
                                     C Tokens
                                                Standard Procedure
                       Structure of C Program
                                                Selecting OS
         Compiling and Executing a C Program


Standard Procedure


  There are basically five steps in the sucessful execution of a
  program:
      Creating a program file (Source File).
      Saving the program (with .c as extension).
      Compliation.
      Linking system library function.
      Running (executing) the program.




                             Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                              Compiling and Executing a C Program
                                   C Tokens
                                              Standard Procedure
                     Structure of C Program
                                              Selecting OS
       Compiling and Executing a C Program


Selecting OS



     DOS Platform:
     Any of the C program environment may be used which are
     IDE.
     Unix Platform:
     Any of the Unix text editor is used to type the C Program,
     with file extention of .c.




                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                                              Compiling and Executing a C Program
                                   C Tokens
                                              Standard Procedure
                     Structure of C Program
                                              Selecting OS
       Compiling and Executing a C Program


Selecting OS cont..



     Now, a C compiler is used to complie the program.
     Normally, CC complier is availeble in Unix. So,
     cc filename.c
     This gives the output as a excutable file named a.out.
     Now, this excutable file can be run through
     ./a.out
     on command prompt of unix.




                           Abhineet Anand     C Language Preliminaries
Introduction to C Language
                            C Tokens
              Structure of C Program
Compiling and Executing a C Program




                         THANK YOU




                    Abhineet Anand     C Language Preliminaries

More Related Content

PPT
Finite automata
PPT
Symbol Table, Error Handler & Code Generation
PDF
NFA to DFA
PDF
Introduction to c++ ppt
PPT
Class and object in C++
PPT
Decision making and looping
PPTX
Introduction TO Finite Automata
Finite automata
Symbol Table, Error Handler & Code Generation
NFA to DFA
Introduction to c++ ppt
Class and object in C++
Decision making and looping
Introduction TO Finite Automata

What's hot (20)

PPTX
Pushdown Automata Theory
DOCX
Os lab file c programs
PPTX
Reduction & Handle Pruning
PPTX
File in C language
PPTX
A* algorithm
PPT
Operators in C++
PPT
Intermediate code generation (Compiler Design)
PPTX
Parsing in Compiler Design
DOC
Notes of c programming 1st unit BCA I SEM
PPT
Unit 3 principles of programming language
PPT
Functions in C++
PPTX
Decision properties of reular languages
PPTX
C tokens
PPTX
Input output statement in C
PPTX
Applications of Mealy & Moore Machine
PPT
Operator Overloading
PDF
Symbol table in compiler Design
PPTX
Java packages
PPTX
String In C Language
PPTX
Decision making statements in C programming
Pushdown Automata Theory
Os lab file c programs
Reduction & Handle Pruning
File in C language
A* algorithm
Operators in C++
Intermediate code generation (Compiler Design)
Parsing in Compiler Design
Notes of c programming 1st unit BCA I SEM
Unit 3 principles of programming language
Functions in C++
Decision properties of reular languages
C tokens
Input output statement in C
Applications of Mealy & Moore Machine
Operator Overloading
Symbol table in compiler Design
Java packages
String In C Language
Decision making statements in C programming
Ad

Viewers also liked (13)

PDF
Finite automata
PDF
Instruction, interrupts & io processing
PPTX
Key concept
PDF
Introduction
PDF
Introduction of c_language
PDF
Micro program
PDF
Instruction code
PDF
Function in C
PDF
Memory organization
PPTX
Algorithms and Flowcharts
Finite automata
Instruction, interrupts & io processing
Key concept
Introduction
Introduction of c_language
Micro program
Instruction code
Function in C
Memory organization
Algorithms and Flowcharts
Ad

Similar to C language preliminaries (20)

PPTX
C programming slide day 01 uploadd by md abdullah al shakil
PPT
C language part 1
PPT
C language part 1
PPTX
Introduction to c language
PPTX
Unit-1 (introduction to c language).pptx
PDF
Programming in c
PPTX
Unit-2_Getting Started With ‘C’ Language (3).pptx
PPTX
Basis Syntax and Introduction to C Programming.pptx
PPTX
C language
PPTX
PPTX
chapter 1.pptx
PPT
C programming presentation for university
PPTX
Lecture01-Introduction-to-C-programming-converted (4).pptx
PDF
Understanding C and its Applications.pdf
PPTX
Introduction to C Programming Language
PDF
C programming
PPTX
C Programming language - introduction
PPTX
Std 10 computer chapter 10 introduction to c language (part1)
PPTX
C Programming UNIT 1.pptx
C programming slide day 01 uploadd by md abdullah al shakil
C language part 1
C language part 1
Introduction to c language
Unit-1 (introduction to c language).pptx
Programming in c
Unit-2_Getting Started With ‘C’ Language (3).pptx
Basis Syntax and Introduction to C Programming.pptx
C language
chapter 1.pptx
C programming presentation for university
Lecture01-Introduction-to-C-programming-converted (4).pptx
Understanding C and its Applications.pdf
Introduction to C Programming Language
C programming
C Programming language - introduction
Std 10 computer chapter 10 introduction to c language (part1)
C Programming UNIT 1.pptx

C language preliminaries

  • 1. Introduction to C Language C Tokens Structure of C Program Compiling and Executing a C Program C Language Preliminaries Abhineet Anand Computer Science and Engg. Department University of Petrolium and Energy Studies, Dehradun November 19, 2012 Abhineet Anand C Language Preliminaries
  • 2. Introduction to C Language Introduction C Tokens History of C Structure of C Program Characteristics of C Compiling and Executing a C Program Introduction C is a high level language. It also has the capability of low level programming. So, sometimes also referred as middle level Programming Language. Best Programming Language for learning procedural programming approach. It was developed at the Bell Laboratory, USA (now AT & T), in 1972. It is the outcome of Dennis Ritchie and Brian Kernighan. Abhineet Anand C Language Preliminaries
  • 3. Introduction to C Language Introduction C Tokens History of C Structure of C Program Characteristics of C Compiling and Executing a C Program History of C C is derived from two early programming languages such as BCPL (Basic Combined Programming Language) and B language developed by Ken Thompson. In 1972 Dennis Ritchie developed a new version of B and named it as C. In 1978, Dennis Ritchie and Brian Kernighan jointly published a detailed description of the C language document. It is Known as K & R C. Some of Shortcomings of K & R C implementation are overcome by ANSI (American National Standard Institute) standards. Abhineet Anand C Language Preliminaries
  • 4. Introduction to C Language Introduction C Tokens History of C Structure of C Program Characteristics of C Compiling and Executing a C Program Characteristics of C C is a general purpose & structured programming language, which helps in development of system software. It has rich set of operators. It provides compact representation for expression. It allows manipulation of internal processor registers. Portability: any C program can be run in different machine with no modification. Rich set of data types and less number of reserved words. Pointer arithmetic and manipulation. Ability to extend itself by adding fuctions to its library. Abhineet Anand C Language Preliminaries
  • 5. Introduction to C Language C Tokens C Tokens Structure of C Program Keywords and Identifiers Compiling and Executing a C Program C Tokens The Basic and Smallest units of any programming language is known as tokens. When a complier complies a program, it recognises those basic units. There are six types of tokens in C. They are: Keywords Identifiers Constants Strings Operators Special Symbols. Each of these tokens is formed with one or more charecters of C language. Abhineet Anand C Language Preliminaries
  • 6. Introduction to C Language C Tokens C Tokens Structure of C Program Keywords and Identifiers Compiling and Executing a C Program Keywords Every word in C program is either a keyword or an identifer. All Keywords must be written in lowercase letters. C is case sensitive language. Keywords supported by ANSI C are: auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile & while. Abhineet Anand C Language Preliminaries
  • 7. Introduction to C Language C Tokens C Tokens Structure of C Program Keywords and Identifiers Compiling and Executing a C Program Identifiers Identifiers are the names given to program elements such as variables, arrays and fuctions. These are sequence of alphabets and digits. Rules for forming identifers names: First charecter must be an alphabet or an underscore. No special Charecter or punctuation symbols are allowed except the underscore "_". No two successive underscore are allowed. Keywords should not be used as identifiers. Abhineet Anand C Language Preliminaries
  • 8. Introduction to C Language Structure of C Program C Tokens Preprocessor Statements Structure of C Program Declarations Compiling and Executing a C Program Structure of C Program preprocessor statement global decleration; main( ) { decleration; statement; } user defined function Abhineet Anand C Language Preliminaries
  • 9. Introduction to C Language Structure of C Program C Tokens Preprocessor Statements Structure of C Program Declarations Compiling and Executing a C Program Preprocessor Statements Begin with # symbol, also called the preprocessor directives. Direct the C preprocessor to include header files and also symbolic constants into C program. Few Statements : # include < stdio.h > : for standard input/output functions. # include "Test.h" : for file inclusion of the header files. # deifne NULL 0 : for defining symbolic constant, NULL=0 Abhineet Anand C Language Preliminaries
  • 10. Introduction to C Language Structure of C Program C Tokens Preprocessor Statements Structure of C Program Declarations Compiling and Executing a C Program Global Declarations Variable or function whose existance is known in main( ) function and other user defined function, are called the global variable. Its decleartion is known as global declarations. Excuation of C program starts with main( ). Abhineet Anand C Language Preliminaries
  • 11. Introduction to C Language Structure of C Program C Tokens Preprocessor Statements Structure of C Program Declarations Compiling and Executing a C Program Declarations Variable Decleration: All Variables, array, function used in C program are decleared and may be initialized with their basic data types. Statements: the instruction to the computer to perform some specific task. They may be: Arithmetic Statements. Input/output Statements. Control Statements. Other Statements. Comments: explantory notes on some instruction, which are not executed and enclosed with in /* & */. Abhineet Anand C Language Preliminaries
  • 12. Introduction to C Language Compiling and Executing a C Program C Tokens Standard Procedure Structure of C Program Selecting OS Compiling and Executing a C Program Compiling and Executing a C Program Compiling a C program means translating it into machine language.C Compiler does that for C pragrams. Various tools are availble which gives the facility of writing, editing, debugging and excuting C language program. This type of environment is known as Inetegrated Development Environment (IDE). Examples : Turbo C, Borland C/C++, ANSI C and many more. Abhineet Anand C Language Preliminaries
  • 13. Introduction to C Language Compiling and Executing a C Program C Tokens Standard Procedure Structure of C Program Selecting OS Compiling and Executing a C Program Standard Procedure There are basically five steps in the sucessful execution of a program: Creating a program file (Source File). Saving the program (with .c as extension). Compliation. Linking system library function. Running (executing) the program. Abhineet Anand C Language Preliminaries
  • 14. Introduction to C Language Compiling and Executing a C Program C Tokens Standard Procedure Structure of C Program Selecting OS Compiling and Executing a C Program Selecting OS DOS Platform: Any of the C program environment may be used which are IDE. Unix Platform: Any of the Unix text editor is used to type the C Program, with file extention of .c. Abhineet Anand C Language Preliminaries
  • 15. Introduction to C Language Compiling and Executing a C Program C Tokens Standard Procedure Structure of C Program Selecting OS Compiling and Executing a C Program Selecting OS cont.. Now, a C compiler is used to complie the program. Normally, CC complier is availeble in Unix. So, cc filename.c This gives the output as a excutable file named a.out. Now, this excutable file can be run through ./a.out on command prompt of unix. Abhineet Anand C Language Preliminaries
  • 16. Introduction to C Language C Tokens Structure of C Program Compiling and Executing a C Program THANK YOU Abhineet Anand C Language Preliminaries