lesson1- introduction to c.doc

Upload: pavan-vutukuru

Post on 03-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Lesson1- Introduction to C.doc

    1/5

    Introduction to CIntroduction to C 1

    Chapter Outline

    Introduction

    History of C

    Features of C

    Applications of C

    Conclusion

    Journey of thousand miles always begins

    with one step.Chinese Quotation

    Focus on the journey, not on the destination. Joy

    is found not in finishing an activity but in doing it.Greg Anderson

    Time is a companion that goes with us on journey. Itreminds us to cherish each moment, because it will

    never come again. What we leave behind is not as

    important as how we have lived.Jean Luc Picard

  • 7/28/2019 Lesson1- Introduction to C.doc

    2/5

    1.1. Introduction

    A computer needs to be instructed to perform desired task. For this, programs are written using a special

    computer language known as a programming language. Just as in a natural language, a programming

    language consists of set of characters, statements and usage rules that allow the user to communicate

    with computers. A programming language should follow syntax rules to create an accurate program so

    that the computer can yield desired result. One of the most popular programming languages is C.

    1.2. History of C

    By 1960, a numerous collection of programming languages had come into existence, almost each

    for a specific purpose. E.g., COBOL was being used for commercial applications, FORTRAN for

    engineering and scientific applications and so on.

    At this stage, the people started thinking about the language that can program all possible

    applications. Therefore, an International committee was set up to develop such a language. This

    committee came out with a language called ALGOL 60 in 1960. However, ALGOL 60 never really

    became popular because it seemed too general.

    To reduce this generality, a new language called Combined Programming Language (CPL) was

    developed at Cambridge University in 1963. However, CPL turned out to be so big, having so

    many features, that it was hard to learn and difficult to implement.

    Basic Combined Programming Language (BCPL) was developed by Martin Richards at

    Cambridge University in 1967. He aimed to solve the problem of many features to learn by

    bringing CPL down to its basic good features. But, unfortunately, it turned out to be too less

    powerful and too specific.

    Around the same time, a language called B was written by Ken Thompson at American Telegraph

    and Teli-Communications (AT&T) Bell laboratories, as a further simplification of CPL in 1970. But,

    like BCPL, B also turned out to be a very specific.

    Dennis Ritchie inherited the features of both B and BCPL, added some of his own and developed a

    new programming language, C, in 1972.

    For many years, the defacto standard for C was the version supplied with the UNIX. In summer of

    1983, a committee was established to create an ANSI (American National Standards Institute)

    standard that would define the C language. The ANSI C standard was finally adopted in 1989. The

    standard was also adopted by ISO (International Standards Organization) and the resultingstandard was typically referred to as ANSI/ISO standard C. The version of C defined by the 1989

    standard is commonly referred to as C89.

    The work on C continued quietly along, with a new standard fir C being developed. The end result

    was the 1999 standard C (C99). In general, C99 retained nearly all of the features of C89. The

    C99 standardization committee focused on two main areas: the addition of several numeric

    libraries and the development of some special-use, but highly innovative, new features, such as

  • 7/28/2019 Lesson1- Introduction to C.doc

    3/5

    variable length arrays. These innovations have once again put C at the forefront of the computer

    language development.

    1.3. Features of C

    1. C is a middle-level language.

    High-level languages have been designed to give better programming efficiency. i.e., faster program

    development.

    Low-level languages have been designed to give better machine efficiency. i.e., faster program execution.

    C stands in between these two categories. Hence, it is often called as a middle-level level language, since

    it was developed to have both: a relatively good programming efficiency and relatively good machine

    efficiency.

    2. C is modular (or) C is procedure-oriented programming language.

    C is modular. The C code should be written in routines called functions. These functions can be reused in

    other applications or programs. By passing pieces of information to these functions, we can create useful

    and reusable code.

    3. C is a language of few words.

    C contains a handful of terms called keywords (some times called as reserved words), which serve as the

    base on which the languages functionality is built. High-level languages have many more keywords (e.g.,

    BASIC has more than 100 keywords). C has 37 keywords (C89 standard defined 32 and C99 standard

    defined 5 more).

    4. C is a portable language.

    Portability means the ability of executing a program on one machine that was written on another

    machine. A C program written on one computer system (e.g., an IBM Pc) can be compiled and run on

    another system (e.g., a DEC VAX system) with little or no modification.

    5. C is a powerful and flexible language.

    What you can accomplish with C is limited only by our imagination. The language itself places no

    constraints on us. C is used for projects as diverse as operating systems, word processors, graphics,

    spreadsheets and even compilers for other languages.

    6. C is a programmers language.

    Surprisingly, not all computer programming languages are for programmers. E.g., BASIC was created

    essentially to allow non-programmers to program a computer to solve relatively simple problems. In

    contrast, C was created, influenced and field-tested by working programmers. The end result is that C

    gives the programmer what the programmer wants: few restrictions, few complaints, block-structure,

    stand-alone functions and compact set of keywords. C helps the programmer to write system programs

    and end-user applications too.

  • 7/28/2019 Lesson1- Introduction to C.doc

    4/5

  • 7/28/2019 Lesson1- Introduction to C.doc

    5/5

    1.4. Applications of C

    The languages such as C++ or Java is evolved from the basic language C. Learning these

    languages is made easy if we had the idea of the basic concepts of programming language that

    were introduced in C.

    Major parts of popular operating systems like Windows, UNIX, Linux is still written in C. Even

    today, when it comes to performance (Speed of execution), nothing beats C. Moreover, if one is toextend the operating system to work with new devices, one needs to write device driver programs.

    These programs are exclusively written in C.

    Mobile devices like cellular phones and palm tops are becoming increasingly popular. Also,

    common consumer devices like microwave ovens, washing machines and digital cameras are

    getting smarter by the day. This smartness comes from a microprocessor, an operating system

    and a program embedded in these devices. These programs not only have to run fast, but also

    have to work in limited amount of memory. No wonder that such programs are written in C. With

    these constraints on time and space, C is the language of choice while building such operating

    systems and programs.

    Many popular games have been built using C. We must have seen several professional 3D

    computer games where the user navigates some object, say a spaceship and fire bullets at the

    invaders. The essence of all such games is speed. Needless to say, such games wont become

    popular, if they take a long time to move the spaceship or to fire a bullet. To match the

    expectations of the player, the game has to react fast to the user inputs. This where C scores

    more over other languages.

    At times, one is required to very closely interact with the hardware devices. Since C provides

    several language elements that make this interaction feasible without compromising theperformance, it is the preferred choice of the programmers.

    1.5. Conclusion

    C is a middle-level programming language that was developed by Dennis Ritchie at AT&Ts Bell labs, USA

    in 1972. C language is procedure-oriented, easy-to-learn, portable, flexible and a programmers language

    developed by working programmers. C acts as a base language for other languages such as C++ and

    Java. By using C language, one can write simple application programs to tedious system programs that

    interact with hardware. Embedded systems programming is best carried out with C.