Introduction to C
Programming
Getting Started with C
The C Character Set
Rules for Constructing Integer Constants
• (a) An integer constant must have at least one digit.
• (b) It must not have a decimal point.
• (c) It can be either positive or negative.
• (d) If no sign precedes an integer constant, it is assumed to be positive.
• (e) No commas or blanks are allowed within an integer constant.
• (f) The allowable range for integer constants is -2147483648 to +2147483647.
• Ex.: 426 ,+782 ,-8000, -760
Rules for Constructing Real Constants
• (a) A real constant must have at least one digit.
• (b) It must have a decimal point.
• (c) It could be either positive or negative.
• (d) Default sign is positive.
• (e) No commas or blanks are allowed within a real constant.
• Ex.: +325.34 ,426.0, -32.76, -48.5792
Rules for Constructing Character Constants
• (a) A character constant is a single alphabet, a single digit or a single special
symbol enclosed within single inverted commas.
• (b) Both the inverted commas should point to the left. For example, ’A’ is a
valid character constant whereas ‘A’ is not.
• Ex.: 'A’, 'I’ ,'5’ ,'='
Rules for Constructing Variable Names
• (a) A variable name is any combination of 1 to 31 alphabets, digits or underscores.
Some compilers allow variable names whose length could be up to 247 characters.
Still, it would be safer to stick to the rule of 31 characters. Do not create
unnecessarily long variable names as it adds to your typing effort.
• (b) The first character in the variable name must be an alphabet or underscore ( _ ).
• (c) No commas or blanks are allowed within a variable name.
• (d) No special symbol other than an underscore (as in gross_sal) can be used in a
variable name.
• Ex.: si_int ,m_hra
C Keywords
Data Type - char
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
Data type: int
-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
int 2 or 4 bytes
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 8 bytes or (4bytes for 32 bit OS) -9223372036854775808 to 9223372036854775807
Floating-Point Types
Type Storage size Value range Precision
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to 1.7E+308 15 decimal places
long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places
Format Specifiers
Escape Sequences