1 / 15

C Programming Language

C Programming Language. Bill Jensen CS 354 May, 3 rd 2007. Catalyst. In late 1960’s Bell Labs left project on Multics, and soon after he and others began working on the Unix Operating System. Ken Thompson wanted a comfortable computing environment of his own design.

josiah
Download Presentation

C Programming Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C Programming Language • Bill Jensen • CS 354 • May, 3rd 2007

  2. Catalyst In late 1960’s Bell Labs left project on Multics, and soon after he and others began working on the Unix Operating System. • Ken Thompson wanted a comfortable computing environment of his own design. • B programming language was created, based on languages used when creating Multics; especially BCPL. • Thompson decided Unix needed a system programming language.

  3. Creation • By 1970 Unix had shown promise and Bell Labs acquired the new DEC PDP-11 • By 1971…We all wanted to create interesting software more easily. • B’s problems – 1) Clumsy Character handling 2) Floating point not available on PDP-11 3) Implied overhead with pointers • Alterations to B and a new name, NB.

  4. Creation - continued • NB proved to be insufficient and with further changes was renamed to C. • Many changes around 1972-3, but main was introduction of preprocessor. • Portability developed as I/O Libraries written by Mike Lesk. • 1977 produced changes focused on portability and type safety. • 1978 Brian Kernighan and Dennis Ritchie Published The C Programming Language.

  5. Control - standardization • Portability tests (Interdata 8/32, DEC VAX 11/780) lead to wide spread use during the 1980’s. • Compilers became available on most every machine architecture. • Wide use, including use on commercial and Government projects lead to establishment of X3J11 committee established by ANSI to produce a standardization of C.

  6. Characteristics • An Imperative, Procedural programming language. • Design based on the implementation of computer processors based upon the von Neumann architecture. • Low level access to memory by machine addresses and typed pointers.

  7. Variables, Types & Operators • Variables - Must begin with letter followed by any number and combination of letters and digits. (strings are implemented as char arrays) • Types – char, int (short, long), float, double • shorts, ints – min 16 bits • Long – min 32 bits • Binary Operators: +, -, *, /, % • Logic Operators: >, >=, <, <=, ==, !=, &&, ||, ! (negate) • Bitwise: &, |, ^, <<, >>, - (unary)

  8. Assignment Expressions • Assignment: =, +=, -=, *=, /=, &=, ^=, |=, <<=, >>= • Most associativity is Left to Right • Ex. x = 1 + 2; • Ex. y += 4; (y = y + 4;)

  9. Control Flow • If-Else, Else-If, Switch, Loops, GOTO • Loops – While, For, Do-while • GOTO and Labels – GOTO’s can be useful in error handling in special cases but usually should be avoided • Labels – same form as a variable followed by a colon • “goto statements should be used rarely, it at all” – Kernighan, Ritchie

  10. Pointers and Arrays • Pointers contain addresses of variables. Ex. int x = 10; // var x has value of 10 int *ptr; // ptr points to the address of an int ptr = &x; // ptr now has value of x (10) Arrays can be declared normally and as pointer arrays. Ex. Int array[] // one dimensional int twoDimArray[][] // two dimensional array * Pointer arrays are usually faster but harder to understand.

  11. Structures • Structures – a collection of one or more variables or any type. • Structures are used to help organize complicated data. Ex. Struct account { char *accountHolder; double checkingBalance; double savingsBalance; }

  12. Conclusion • Readability – overall easy to read and intuitive. Pointers can make reading code difficult. • Simplicity – simple design making c easy to learn and apply. • Orthogonality – c is not very restrictive, which allows some creativity and some higher chances of writing bugged code.

  13. Conclusion - continued • Easy to learn basic concepts. • Lack simple implementation of object oriented programming can make class OOP tedious.

  14. Primary Uses • True to its original purpose C is most often used in systems programming. • Operating Systems • Embedded Systems • Intermediate Language for higher-level languages * Java • Computer Game Programming

  15. Bibliography • Kernighan, Brian W., and Dennis M. Ritchie. The C Programming Language. New Jersey: Prentice Hall, 1988. • Sebesta, Robert W. Concepts of programming languages. Boston: Pearson, 2006. • Ritchie, Dennis M. The Development of the C Language*. Murray Hill, NJ: . • "C (programming language) • ." wikipedia.org. April, 25th 2007.<http://en.wikipedia.org/wiki/C_programing_language>.

More Related