Constant Variables and Data Types
Constant Variables and Data Types
Stapes in learning C
• Stapes of learning C is similar to learning English language.
Stapes in learning C:
Alphabets Constants
Digits Variables Instructions Program
Special symbols Keywords
Character Set of C
Character set is used to represent the information.
Letters (Alphabets)
Uppercase A,B,C,………….Y,Z
Lowercase a,b,c,…………..y,z
Character Set of C…
Digits
All decimal digits 0,1,2,3,4,5,6,7,8,9
Special Characters
, Comma ‘ apostrophe
. Period (dot) “ Quotation mark
; semicolon ! Exclamation mark
: colon | vertical bar
? Question marks / slash
\ backslash ~ tilde
_ Under score $ dollar sign
% percent sign & ampersand
^ caret * asterisk
- Minus sign + plus sign
Character Set of C…
Special Characters…..
White Spaces
Types:
C tokens
C tokens
Keywords
Keywords Strings
Strings Special
Special
Identifiers Constants
Identifiers Constants Operators
Operators
(float,
(float, (“abc”,
(“abc”, Symbols
Symbols
(a, rate)
(a, rate) (-15.2,10)
(-15.2,10) (+,-,)
(+,-,)
while)
while) ”year”)
”year”) (? ,, [)[)
(?
C constants
A fixed value that do not change during the execution
of program.
1. Primary constants
a. Integer constants
b. Real constant
c. Character Constant
2. Secondary Constants
a. Array
b. Pointers
c. Structure
d. Union
e. Enum etc.
Rules for Integer Constants
1. An integer constant must have at least one digit.
2. It must not have a decimal point.
3. It could be either positive or negative.
4. If no sign precedes an integer constant it is
assumed to be positive.
5. No commas and blanks are allowed within an
integer constant.
6. The allowable range for integer constant is -32768
to32767 for 16-bit computer.
Ex: 467,+789,-8000
Rules for Real Constants
1. A real constant must have at least one digit.
2. It must have a decimal point.
3. It could be either positive or negative.
4. Default sign is positive.
5. No commas or blanks are allowed within a real
constant.
Ex: +32.33
432.32
-39.3
Rules for Character Constants
1. A character constant is a single alphabet, a single
digit or a single special symbol enclosed within
single inverted commas.
2. The maximum length of a character constant can
be 1 character.
Ex: ‘A’
‘I’
‘5’
‘=’
C Variables
Variables: Quantity that may vary during program
execution.