2/12/2010




                                                                  t
                                                                                                                                  y
                                                                            Keep your notebook with you.




                           C
                                                                   Write important point and questions that comes in your mind

                                                                        Solve Mind band exercise.

                                          Programming
                                                                                                                                  C
                                                                                                          Rewind when not clear

                                            Language
                                                                                 Ask Questions by call or SMS or by mail

                                   By:
                                                                   Keep Watching Keep Learning
                        Yogendra Pal
                 yogendra@learnbywatch.com
                                                                   THIS IS INTRODUCTION
                      Dedicated to My mother and Father




                                                                                                      2




                        Computer                                                         Computer…
• Electronic Device                                               • Two very important for a programmer
• Store, Manipulate and Transmit data.                              – Numeric
• Data can be                                                       – Character
    – Numeric                                                     • Scientific and Engineering Applications
    – Character (Name, Address etc.)                                – Numeric
    – Graphics data (Charts, Photographs, Videos)                 • Business applications
    – Sound (Music, Speech etc.)                                    – Numeric and Character


                                      3                                                               4




                          Memory                                                           Memory…
•   Every information is stored in binary code.                   • Bit is the smallest unit of information storage.
•   Binary code is the sequence of 0s and 1s.                     • Bit consists a single binary digit (0 or 1).
•   0 and 1 are called bits.                                      • We can interpreted 0 and 1 as:
•   0 represents OFF and 1 represents ON.                           – 0 : False : Off
•   8 bits makes 1 byte.                                            – 1 : True : On
             7    6       5       4       3      2        1   0



• Character takes one byte to store.
                                      5                                                               6




                                                                                                                                             1
2/12/2010




                     Memory…                                       Machine needs instructions
•
                                                                               o
    1 bit consists 0 or 1.
•
•
    8 bits makes a byte.
    210 (1024) byte make a Kilobyte or KB.
                                                             I
•   210 (1024) Kilobyte make a Megabyte or MB.
•   210 (1024) Megabyte make a Gigabyte or GB.
•   210 (1024) Gigabyte make a Terabyte or TB.
            Bit < Byte < KB < MB < GB < TB
                                                                                ć
                              7                                                          8




          Programming Language                                          Machine Language
• Machine Language                                          • Strings of numbers giving machine specific
• Assembly Language                                           instructions.
• High-Level Language                                       • Also known as Machine code.
                                                              Example:
                                                                 +1300042774
                                                                 +1400593419
                                                                 +1200274027




                              9                                                          10




             Machine Language…                                          Assembly Language
• Very Few programs are written in machine                  • English-like abbreviations representing
  language because:-                                          elementary computer operations.
    – It is very difficult to work with machine language.   • Simpler than machine language.
    – Program written for one type of computer will not          Example:
      run on other type of computer (Each type of                       LOAD BASEPAY
                                                                        ADD OVERPAY
      computer has it’s own instruction set).
                                                                        STORE GROSSPAY

                                                            • Translate in machine code before execute.
                                                            • Translation is done by assembler.
                             11                                                          12




                                                                                                                  2
2/12/2010




              High-level Languages                               High level languages…
• Codes similar to everyday English (Easy to            • The program written in high level language is
  understand).                                            known as source code or source program.
• Use mathematical notations.                           • The compiled source code results in machine-
• Example                                                 language.
  – grossPay = basePay + overTimePay
                                                        • Machine language code is also known as
• Translate in machine code before execute.
                                                          object code or object program.
• Translation is done by compiler or
  interpreter.

                              13                                                14




           Compiler vs. Interpreter                                       Program
• Interpreter reads the source code one line at a       • Using programming language we create
  time convert it into machine code.                      instructions or set of instructions.
• Compiler reads the entire program and                 • This set of instructions is also knows as
  converts it into machine code.                          computer program or software program or
• machine code is a code that the computer can            just program.
  run directly.                                         • Example programs or softwares:
• machine code also known as object code or               – Word processing program
  binary code.                                            – Computer Games or video games
                              15                                                16




                      History of C                             C: A Middle Level Language
• Evolved by Dennis Ritchie in 1970 at Bell             • Best elements of high level language and
  Telephone Laboratories from two previous                control and flexibility of assembly language.
  programming languages, BCPL and B.
                                                        • C allows the direct manipulation of bits, bytes
• Used to develop UNIX.                                   and addresses.
• Used to write modern operating systems.               • C has several built in data types.
• Hardware independent (portable).
                                                        • Permits type conversion.
• Standard created in 1989, updated in 1999.
                                                        • No run time error checking.
       BCPL                  B              C
    Martin Richards     Ken Thompson   Dennis Ritchie   • Well suited for system-level programming.
                              17                                                18




                                                                                                             3
2/12/2010




          The C Standard Library                                           C Standard Library…
• C programs consist of pieces/modules called                 • Avoid re-inventing the wheel
  functions.                                                      – If a premade function exists, generally best to use it
  – A programmer can create his own functions.                      rather than write your own
     • Advantage: the programmer knows exactly how it works       – Library functions carefully written, efficient, and
     • Disadvantage: time consuming                                 portable
  – Programmers will often use the C library
    functions.
     • Use these as building blocks

                               19                                                           20




     Other High-level Languages                                          Structured Programming
• Other high-level languages                                  • Disciplined approach to writing programs.
  – FORTRAN                                                   • Functions are the building blocks of programs.
     • Used for scientific and engineering applications
                                                              • Allow you to code separate tasks in a program,
  – COBOL
                                                                make your program modular.
     • Used to manipulate large amounts of data
  – Pascal                                                    • Clear, easy to test and debug and easy to
     • Intended for academic use                                modify.
                                                              • C is a structured programming language.

                               21                                                           22




             Library and Linking                                         Program Development
• Library : Collection of functions.                          • Edit        : Program is created in the editor and
                                                                              stored on disk.
• Linker : Combines the called function object                •   Preprocess: Preprocess program processes the code
  code with the code you written.                             •   Compile : Compiler creates object code and stores it
                                                                  on disk.
                                                              •   Link      : Linker links the object code with the
                                                                              libraries.
                                                              •   Load      : Loader loads program in memory.
                                                              •   Execute : CPU takes each insruction and executes it.

                               23                                                           24




                                                                                                                              4
2/12/2010




             Form of C program                                               Mind Bend
• The main() function must present in program.    • Write 4 different data types.
• Keywords can not used as a variable name or a   • What is meant by a computer program?
  function name.                                  • Differentiate bit & byte?
• Case sensitive language.                        • What is a machine language? How it is
                                                    different from High level language?
   – else  ELSE 
                                                  • What are the advantages of high level
• It may have many functions.                       language? Give some examples of high level
                                                    language.

                         25                                                              26




                                                                   To get complete benefit solve all the quiz on
                  Mind Bend                                                  www.learnbywatch.com


•   Differentiate Compiler and Interpreter.                         For any problem in this tutorial mail me at
                                                                          yogendra@learnbywatch.com
•   What is source program?                                                   with the subject “C”

•   What is object program?                                               For Other information mail at
•   Who develop the C language and where?                                   info@learnbywatch.com

•   Can we use uppercase in C program?
                                                      Keep Watching Keep Learning
•   Computer is an __________ device.
                                                      NEXT IS C BASICS
•   Binary code is the sequence of _ & _.
                         27




                                                                                                                          5

Introduction handout

  • 1.
    2/12/2010 t y Keep your notebook with you. C Write important point and questions that comes in your mind Solve Mind band exercise. Programming C Rewind when not clear Language Ask Questions by call or SMS or by mail By: Keep Watching Keep Learning Yogendra Pal yogendra@learnbywatch.com THIS IS INTRODUCTION Dedicated to My mother and Father 2 Computer Computer… • Electronic Device • Two very important for a programmer • Store, Manipulate and Transmit data. – Numeric • Data can be – Character – Numeric • Scientific and Engineering Applications – Character (Name, Address etc.) – Numeric – Graphics data (Charts, Photographs, Videos) • Business applications – Sound (Music, Speech etc.) – Numeric and Character 3 4 Memory Memory… • Every information is stored in binary code. • Bit is the smallest unit of information storage. • Binary code is the sequence of 0s and 1s. • Bit consists a single binary digit (0 or 1). • 0 and 1 are called bits. • We can interpreted 0 and 1 as: • 0 represents OFF and 1 represents ON. – 0 : False : Off • 8 bits makes 1 byte. – 1 : True : On 7 6 5 4 3 2 1 0 • Character takes one byte to store. 5 6 1
  • 2.
    2/12/2010 Memory… Machine needs instructions • o 1 bit consists 0 or 1. • • 8 bits makes a byte. 210 (1024) byte make a Kilobyte or KB. I • 210 (1024) Kilobyte make a Megabyte or MB. • 210 (1024) Megabyte make a Gigabyte or GB. • 210 (1024) Gigabyte make a Terabyte or TB. Bit < Byte < KB < MB < GB < TB ć 7 8 Programming Language Machine Language • Machine Language • Strings of numbers giving machine specific • Assembly Language instructions. • High-Level Language • Also known as Machine code. Example: +1300042774 +1400593419 +1200274027 9 10 Machine Language… Assembly Language • Very Few programs are written in machine • English-like abbreviations representing language because:- elementary computer operations. – It is very difficult to work with machine language. • Simpler than machine language. – Program written for one type of computer will not Example: run on other type of computer (Each type of LOAD BASEPAY ADD OVERPAY computer has it’s own instruction set). STORE GROSSPAY • Translate in machine code before execute. • Translation is done by assembler. 11 12 2
  • 3.
    2/12/2010 High-level Languages High level languages… • Codes similar to everyday English (Easy to • The program written in high level language is understand). known as source code or source program. • Use mathematical notations. • The compiled source code results in machine- • Example language. – grossPay = basePay + overTimePay • Machine language code is also known as • Translate in machine code before execute. object code or object program. • Translation is done by compiler or interpreter. 13 14 Compiler vs. Interpreter Program • Interpreter reads the source code one line at a • Using programming language we create time convert it into machine code. instructions or set of instructions. • Compiler reads the entire program and • This set of instructions is also knows as converts it into machine code. computer program or software program or • machine code is a code that the computer can just program. run directly. • Example programs or softwares: • machine code also known as object code or – Word processing program binary code. – Computer Games or video games 15 16 History of C C: A Middle Level Language • Evolved by Dennis Ritchie in 1970 at Bell • Best elements of high level language and Telephone Laboratories from two previous control and flexibility of assembly language. programming languages, BCPL and B. • C allows the direct manipulation of bits, bytes • Used to develop UNIX. and addresses. • Used to write modern operating systems. • C has several built in data types. • Hardware independent (portable). • Permits type conversion. • Standard created in 1989, updated in 1999. • No run time error checking. BCPL B C Martin Richards Ken Thompson Dennis Ritchie • Well suited for system-level programming. 17 18 3
  • 4.
    2/12/2010 The C Standard Library C Standard Library… • C programs consist of pieces/modules called • Avoid re-inventing the wheel functions. – If a premade function exists, generally best to use it – A programmer can create his own functions. rather than write your own • Advantage: the programmer knows exactly how it works – Library functions carefully written, efficient, and • Disadvantage: time consuming portable – Programmers will often use the C library functions. • Use these as building blocks 19 20 Other High-level Languages Structured Programming • Other high-level languages • Disciplined approach to writing programs. – FORTRAN • Functions are the building blocks of programs. • Used for scientific and engineering applications • Allow you to code separate tasks in a program, – COBOL make your program modular. • Used to manipulate large amounts of data – Pascal • Clear, easy to test and debug and easy to • Intended for academic use modify. • C is a structured programming language. 21 22 Library and Linking Program Development • Library : Collection of functions. • Edit : Program is created in the editor and stored on disk. • Linker : Combines the called function object • Preprocess: Preprocess program processes the code code with the code you written. • Compile : Compiler creates object code and stores it on disk. • Link : Linker links the object code with the libraries. • Load : Loader loads program in memory. • Execute : CPU takes each insruction and executes it. 23 24 4
  • 5.
    2/12/2010 Form of C program Mind Bend • The main() function must present in program. • Write 4 different data types. • Keywords can not used as a variable name or a • What is meant by a computer program? function name. • Differentiate bit & byte? • Case sensitive language. • What is a machine language? How it is different from High level language? – else  ELSE  • What are the advantages of high level • It may have many functions. language? Give some examples of high level language. 25 26 To get complete benefit solve all the quiz on Mind Bend www.learnbywatch.com • Differentiate Compiler and Interpreter. For any problem in this tutorial mail me at yogendra@learnbywatch.com • What is source program? with the subject “C” • What is object program? For Other information mail at • Who develop the C language and where? info@learnbywatch.com • Can we use uppercase in C program? Keep Watching Keep Learning • Computer is an __________ device. NEXT IS C BASICS • Binary code is the sequence of _ & _. 27 5