Nothing Special   »   [go: up one dir, main page]

C Lecture#3 (22/10/2022)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

Chapter 2

CONSTANTS, VARIABLES AND DATA TYPES


Character Set
• Every C program contains statements.
• These statements are constructed using words and these words are
constructed using characters from C character set.
Character Set Examples

Alphabets • Lower case Letters: a,b,c,……….,y,z.


• Upper Case Letters: A,B,C,………….,Y,Z.
Digits Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Special Characters ~@#$%^&*()_-+={}[];:'"/?.


> , < \ | tab
White space Characters. \b \t \v \r \f \n \\ \’ \" Double quote
\? \0
C Tokens
• C tokens are the basic buildings blocks in C language which are constructed
together to write a C program.
• Each and every smallest individual units in a C program are known as C tokens.
Keywords
• All keywords have fixed meanings and these meanings cannot be changed.
• All keywords must be written in lowercase.
Identifiers
• Identifiers refer to the name of variables, functions and arrays.
• These are user-defined names and consists of a sequence of letters and digits, with a letter
as a first character.
Difference between Keyword and Identifier
Constants
• Constants refer to fixed values that the program may not alter during its
execution.
Integer Constants
Integer Constants

• Decimal constant consists of a set of digits 0 through 9,


preceded by an optional –or + sign.
• An octal integer constant consists of any combination of
digits from the set 0 through 7, with an leading 0.
• A sequence of digit preceded by Ox or OX is considered as
hexadecimal. They may also include alphabets A through F
or a through f. The letter A through F represent the numbers
10 through 15.
Why do we use hexadecimal number system?

• It is much easier for humans to read hexadecimal numbers


than binary numbers.
• For example, the hexadecimal number 0x2F5B translates to
the binary number 0010 1111 0101 1011.
• https://www.binaryhexconverter.com/binary-to-hex-convert
er
• A common use of hexadecimal numbers is to describe colors
on web pages. Each of the three primary colors (i.e., red,
green and blue) is represented by two hexadecimal digits to
create 255 possible values, thus resulting in more than 16
million possible colors.

You might also like