Presentation is loading. Please wait.

Presentation is loading. Please wait.

C Programming language

Similar presentations


Presentation on theme: "C Programming language"— Presentation transcript:

1 C Programming language
" ‘white book’ or ‘K&R’ "

2 C Language Programming History
UNIX developed c 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 A totally new language ``C'' a successor to ``B''. c 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 variables   C 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.


Download ppt "C Programming language"

Similar presentations


Ads by Google