1 / 11

C Programming language

C Programming language. " ‘white book’ or ‘K&R’ ". C Language Programming History. UNIX developed c. 1969 -- DEC PDP-7 Assembly Language. BCPL -- a user friendly OS providing powerful development tools developed from BCPL. Assembler tedious long and error prone.

urvi
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 " ‘white book’ or ‘K&R’ "

  2. C Language Programming History • UNIX developed c. 1969 -- DEC PDP-7 Assembly Language. • BCPL -- a user friendly OS providing powerful development tools developed from BCPL. Assembler tedious long and error prone. • A new language ``B'' a second attempt. c. 1970. • A totally new language ``C'' a successor to ``B''. c. 1971. • By 1973 UNIX OS almost totally written in ``C''.

  3. C Language Design Goals • It to be compiled using a relatively straightforward compiler. • Provide low-level access to memory. • Provide language constructs that map efficiently to machine instructions. • Require minimal run-time support. • C was therefore useful for many applications that had formerly been coded in assembly language.

  4. C Language Characteristics • C has facilities for structured programming and allows lexical variable scope and recursion. • Parameters of C functions are always passed by value. • Pass-by-reference is achieved in C by explicitly passing pointer values. • C program source text is free-format, using semicolon as a statement terminator (not a delimiter).

  5. More Specific Characteristics • Non-nestable function definitions, although variables may be hidden in nested blocks. • Partially weak typing; for instance, characters can be used as integers. • Array indexing as a secondary notion, defined in terms of pointer arithmetic. • Function pointers allowing for a rudimentary form of closures and runtime polymorphism.

  6. C Program Structure A C program basically has the following form : • Preprocessor Commands • Type definitions • Function prototypes -- declare function types and variables passed to function. • Variables • Functions

  7. C language Function • C programming must have a main() function. • A function has the form : type function_name (parameters) { local variablesC Statements }

  8. C Language Variables • C has the following simple data types : • To declare a variable in C, do :     var_type list variables;

  9. Defining Global Variables • Global variables are defined above main() in the following way • Example : short number,sum; int bignumber,bigsum; char letter;   main() {   }

  10. Printing Out and Inputting Variables • C uses formatted output. The printf function has a special formatting character (%) -- a character following this defines a certain format for a variable : %c -- characters %d -- integers %f -- floats     e.g. printf(``%c %d %f'',ch,i,x); • Scanf() is the function for inputting values to a data structure: Its format is similar to printf : i.e. scanf(``%c %d %f'',&ch,&i,&x);

  11. Using C Language Programming • C's primary use is for "system programming", including implementing operating systems and embedded system applications. • C has also been widely used to implement end-user applications. • C source code is then input to a C compiler, which then outputs finished machine or object code. • One consequence of C's wide acceptance and efficiency is that the compilers, libraries, and interpreters of other higher-level languages are often implemented in C.

More Related