SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
 
File in C language
File in C languageFile in C language
File in C language
 
C keywords and identifiers
C keywords and identifiersC keywords and identifiers
C keywords and identifiers
 
String functions in C
String functions in CString functions in C
String functions in C
 
Features of c language 1
Features of c language 1Features of c language 1
Features of c language 1
 
Learn c++ Programming Language
Learn c++ Programming LanguageLearn c++ Programming Language
Learn c++ Programming Language
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
POINTERS IN C
POINTERS IN CPOINTERS IN C
POINTERS IN C
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
C basics
C   basicsC   basics
C basics
 
C language ppt
C language pptC language ppt
C language ppt
 
Character set of c
Character set of cCharacter set of c
Character set of c
 

Andere mochten auch (13)

Finite automata
Finite automataFinite automata
Finite automata
 
Ndfa
NdfaNdfa
Ndfa
 
Instruction, interrupts & io processing
Instruction, interrupts & io processingInstruction, interrupts & io processing
Instruction, interrupts & io processing
 
Key concept
Key conceptKey concept
Key concept
 
String
StringString
String
 
Introduction
IntroductionIntroduction
Introduction
 
Arrays
ArraysArrays
Arrays
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
 
Micro program
Micro programMicro program
Micro program
 
Instruction code
Instruction codeInstruction code
Instruction code
 
Function in C
Function in CFunction in C
Function in C
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 

Ähnlich wie C language preliminaries

C programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakilC programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakilZenith SVG
 
C language part 1
C language part  1C language part  1
C language part 1JyothiG33
 
Unit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptxUnit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptxsaivasu4
 
Unit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxUnit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxSanketShah544615
 
C programming presentation for university
C programming presentation for universityC programming presentation for university
C programming presentation for universitySheikh Monirul Hasan
 
Lecture01-Introduction-to-C-programming-converted (4).pptx
Lecture01-Introduction-to-C-programming-converted (4).pptxLecture01-Introduction-to-C-programming-converted (4).pptx
Lecture01-Introduction-to-C-programming-converted (4).pptxMdMuaz2
 
Understanding C and its Applications.pdf
Understanding C and its Applications.pdfUnderstanding C and its Applications.pdf
Understanding C and its Applications.pdfAdeleHansley
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageRamaBoya2
 
C Programming language - introduction
C Programming  language - introduction  C Programming  language - introduction
C Programming language - introduction GopikaS12
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Nuzhat Memon
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptxMugilvannan11
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I vampugani
 

Ähnlich wie C language preliminaries (20)

C programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakilC programming slide day 01 uploadd by md abdullah al shakil
C programming slide day 01 uploadd by md abdullah al shakil
 
C language part 1
C language part  1C language part  1
C language part 1
 
C language part 1
C language part  1C language part  1
C language part 1
 
Introduction to c language
Introduction to c language Introduction to c language
Introduction to c language
 
Unit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptxUnit-1 (introduction to c language).pptx
Unit-1 (introduction to c language).pptx
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Unit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptxUnit-2_Getting Started With ‘C’ Language (3).pptx
Unit-2_Getting Started With ‘C’ Language (3).pptx
 
C language
C languageC language
C language
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
C programming presentation for university
C programming presentation for universityC programming presentation for university
C programming presentation for university
 
Lecture01-Introduction-to-C-programming-converted (4).pptx
Lecture01-Introduction-to-C-programming-converted (4).pptxLecture01-Introduction-to-C-programming-converted (4).pptx
Lecture01-Introduction-to-C-programming-converted (4).pptx
 
Understanding C and its Applications.pdf
Understanding C and its Applications.pdfUnderstanding C and its Applications.pdf
Understanding C and its Applications.pdf
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 
C programming
C programmingC programming
C programming
 
C programming
C programmingC programming
C programming
 
C Programming language - introduction
C Programming  language - introduction  C Programming  language - introduction
C Programming language - introduction
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 

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