Professional Documents
Culture Documents
Assistant Professor
ajay.cse@iitbhu.ac.in
The smallest individual units are known as C tokens. C has six types
of tokens as follows:
1
The range of an Integer constant depends upon the compiler.
Dr. Ajay Pratap (IIT (BHU), Varanasi) C Fundamentals ajay.cse@iitbhu.ac.in 8 / 33
Rules for Constructing Real Constants
Real constants are often called Floating Point constants. The real
constants could be written in two forms—Fractional form and
Exponential form.
A real constant must have at least one digit.
It must have a decimal point.
It could be either positive or negative.
Default sign is positive.
No commas or blanks are allowed within a real constant.
Examples: +325.34, 426.0, -32.76, -48.5792.
Real constants are often called Floating Point constants. The real
constants could be written in two forms—Fractional form and
Exponential form.
A real constant must have at least one digit.
It must have a decimal point.
It could be either positive or negative.
Default sign is positive.
No commas or blanks are allowed within a real constant.
Examples: +325.34, 426.0, -32.76, -48.5792.
The exponential form of representation of real constants is usually
used if the value of the constant is either too small or too large.
In exponential form of representation, the real constant is represented
in two parts. The part appearing before ‘e’ is called mantissa,
whereas the part following ‘e’ is called exponent.
Dr. Ajay Pratap (IIT (BHU), Varanasi) C Fundamentals ajay.cse@iitbhu.ac.in 9 / 33
Rules for Constructing Real Constants
1
ASCII is the acronym for the American Standard Code for Information Interchange.
It is a code for representing 128 English characters as numbers, with each letter assigned
a number from 0 to 127. For example, the ASCII code for uppercase M is 77. Most
computers use ASCII codes to represent text, which makes it possible to transfer data
from one computer to another.
Dr. Ajay Pratap (IIT (BHU), Varanasi) C Fundamentals ajay.cse@iitbhu.ac.in 16 / 33
Chars, signed and unsigned
Both, signed and unsigned chars, occupying one byte each, but
having different range
char ch = ’A’ ;
Here what gets stored in ch is the binary equivalent of the ASCII
value of ‘A’ (i.e. binary of 65).
A signed char is same as an ordinary char and has a range from -128
to +127; whereas, an unsigned char has a range from 0 to 255.
1
ASCII is the acronym for the American Standard Code for Information Interchange.
It is a code for representing 128 English characters as numbers, with each letter assigned
a number from 0 to 127. For example, the ASCII code for uppercase M is 77. Most
computers use ASCII codes to represent text, which makes it possible to transfer data
from one computer to another.
Dr. Ajay Pratap (IIT (BHU), Varanasi) C Fundamentals ajay.cse@iitbhu.ac.in 17 / 33
Floats and Doubles
A float occupies four bytes in memory and can range from -3.4e38 to
+3.4e38.
Double data type occupies 8 bytes in memory and has a range from
-1.7e308 to +1.7e308.
To fully define a variable one needs to mention not only its ‘type’ but
also its ‘storage class’.
In other words, not only do all variables have a data type, they also
have a ‘storage class’.
To fully define a variable one needs to mention not only its ‘type’ but
also its ‘storage class’.
In other words, not only do all variables have a data type, they also
have a ‘storage class’.
Storage classes have defaults.
From C compiler’s point of view, a variable name identifies some
physical location within the computer where the string of bits
representing the variable’s value is stored.
Values are stored in memory and CPU registers.
It is the variable’s storage class that determines in which of these two
locations the value is stored.
Example: