Académique Documents
Professionnel Documents
Culture Documents
History of C
1969 By Dannis Ratchie On a DEC PDP-11 that used the UNIX Operating System Result of development process with an older language called BCPL 1970 A new language ''B'' a second attempt. c. 1971 A totally new language ''C'' a successor to ''B''. 1973 UNIX OS almost totally written in ''C''. 1990 ANSI C becomes available
Eastern University
C Basics (Cont.)
Characteristics of C
Small size. Extensive use of function calls. Structured language.
Pointer implementation - extensive use of pointers for memory, array, structures and functions.
Eastern University 2
C Basics (Cont.)
Eastern University
C Library
All C programs include calls to various functions for performing input/output (I/O) operations, high-level mathematical operations, or character handling. Cs standard library contains these functions. All C compilers come with a standard library of functions that perform most commonly needed tasks.
Eastern University
C Linker
Linker combines the original program object code with the object code found in the standard library for the declared header file. This process is called the Linking. C compiler have their own linker.
Eastern University
Compiler
Executable Code
Eastern University
Eastern University
Sample Program
Eastern University
Programming in C
Constants, Variables & Data Types
Eastern University
C Tokens
Smallest individual units are known as tokens C has six types of tokens
Tokens
Keywords
float while
Constants
-15.5 100
Strings
ABC year
Operators
+ * /
Identifiers
ch amount
Special Symbols
[] ()
Eastern University
10
Keyword Identifier
Keyword: All keywords have fixed meanings and these meanings can not be changed Keywords serve as basic building blocks for program statements Example: float, while, switch
Eastern University 11
Identifiers: Identifiers refer to the names of variables, functions and arrays Identifiers are user-defined names and consists of a sequence of letters and digits Example: amount, salary
Eastern University
12
Identifiers (Cont.)
Eastern University
13
Constants
Constants refer to fixed values that do not change during program execution
Constants
Numeric Constants
Character Constants
Integer Constants
142 -453
Real Constants
.0084 -4.5
Eastern University
14
Eastern University
15
Modifiers
Basic data types have various modifiers preceding them which alters the meaning of the basic data types. The list of modifiers is
Eastern University
16
Data Types
Type char / signed char unsigned char int / signed int unsigned int long int float double Size (Bits) 8 8 16 16 32 32 64 Range
-127 to 127 0 to 255 -32,767 to 32,767 0 to 65,535 -2,147,483,647 to 2,147,483,647 1E-37 to 1E+37 with 6 digits of precision 1E-37 to 1E+37 with 10 digits of precision
Eastern University
17
Variables
A variable is a named location in memory that is used to hold a value that can be modified by the program
Eastern University
18
Variables (Cont.)
Variable declaration: type variable_list; It tells the compiler what the variable name is It specifies what type of data the variable will hold Example: int i,j; unsigned int s; double b;
Eastern University 19
Variable Initializations
Example:
int y=10; char ch='A'; double b=143.56;
Eastern University
20
Local Variables
Variables that are declared inside a function are called local variables Example:
# include <stdio.h> # include <conio.h> int main() { int x; x=10; printf("%d", x); getch(); return 0; }
Eastern University 21