Lecture 2 Programming Language C
Lecture 2 Programming Language C
Language
v Language: A language is a structured system for communication.
v Natural Language: A structured system for communication between two
or more human beings. For example, Bangla, English, etc.
v Programming Language: A structured system of writing programs for
either (i) communication between two or more machines; or (ii) human
machine interaction.
Constituents of Language
Natural Language Programming Language
Letter Character
Alphabet Character Set
Word Token
Sentence Statement
Essay Program
Character Set
v Computer can store or recognize only 0 and 1. Letter or character like A, B can
be stored or recognized by a computer. Hence, the characters are
represented by some numbers, known as codes. For example, ‘A’ is
represented by 65, ‘a’ is represented by 97, ‘0’ is represented by 48 and so
on.
v In America, 128 characters are coded with the numbers ranges from 0 to 127,
which are known as ASCII (American standard code for information
interchange). Another 128 characters are coded with the numbers ranges
from 128 to 255, which are known as extended ASCII. All of these 256
characters are supported by C programming. 8 bits or 1 byte memory is used
to represent an ASCII Character.
v Later on, all the symbols used in worldwide languages are coded using 16 bits
or 2 bytes, which is known as UniCode (Universal codes). A Maximum of
65536 characters can be coded using Unicode. C programming does not
support Unicode.
v Each character is represented within single quotes like ‘A’, ‘B’, ‘0’ and so on.
Escape Sequence
v There are some unprintable characters, which are followed by a backslash (\)
and performs some specific tasks, are known as escape sequence.
v Some escape sequence with their details are given below:
Escape Sequence Character ASCII Code
\0 NULL Character 0
\a Bell 7
\b Backspace 8
\t Horizontal Tab 9
\v Vertical Tab 11
\n Newline 10
\r Carriage return 13
\’’ Quotation Mark 34
\’ Apostrophe 39
\? Question 63
\\ Backslash 92
Token
Classification of Tokens
Token
Variable Constant
Identifier
Global Local
void main(){
int x = 5, y = 7;
add(x, y);
printf(“The sum is %d.”, sum);
}
void add(int p, int q){
sum = p + q;
}
Delimiters/Punctuations
vDelimiter: A delimiter is a sequence of one or more characters
that specifies the boundary or acts as a separator.