CHAPTER4
CHAPTER4
• Using a const keyword :To ensures that its value remains unchanged
in the program.
Syntax: const data_type var_name=value;
EX: const int x=40;
Following are the rules used to
define the symbolic constant:
• Symbolic name is similar to variable but it is not variable.
Symbolic name is reference or information. But variable name represents what
information the variable contains.
• No blank space is allow between ‘#’ and ‘define’ word.
• ‘#’ must be first in the line.
• A blank space is require between ‘#define’ and ‘symbolic name’ & between
‘symbolic name’ and ‘constant value’
• It is not statement so it does not end with semicolon
• You cannot put assignment operator ‘=’ between ‘symbolic name’ and constant
value.
• You can put anywhere in program but before it is used in the program.
Data Types:
• The 4 basic data types supported by C are
1. Fundamental / Primary Data type
2. User defined Data type
3. Derived data type
4. Empty dataset
MEMORY SIZE:
Bit= 0 or 1
1nibble=4bits
1byte=8bits
1KB (kilo byte)=1024bytes
1MB(mega byte)=1024KB
1GB(giga byte)=1024MB
1TB(tera byte)=1024GB
1PB(peta byte)=1024TB
1HB(Hexa byte)=1024PB
Primary Data Types:
All C compilers support this data type. Primary data types can be
classified as follows
1. Integer
2. Floating point
3. Character
Integer Data Type:
• Integers are whole numbers with a range of values. Integers occupy one word of
storage.
• In a 16-bit machine, the range of integers is -32768 to+32767
• In order to provide some control over a range of numbers and storage space, C
has 3 classes of storage for integers namely, short int, int and long int in both
signed and unsigned format
• Short int is used for small range of values and requires half the amount of
storage as a regular int number uses.
• Long int requires double the storage as an int value.
• In unsigned integers, all the bits in the storage are used to store the magnitude
and are always positive.
Floating point DataType:
• All floating point numbers require 32 bits with 6 digits of precision
• They are defined in C using the keyword float
• For higher precision, double data type can be used.
• A double type number uses 64 bits (8 bytes) giving a precision of 14
digits.
• Range of values for double type is 1.7E-308 to 1.7E+308
• To extend the precision further, we can use long double which uses 80
bits.
Character DataType:
• A single character can be defined as a character data type using the
keyword char
• Characters usually need 8 bits for storage
• The qualifier signed or unsigned can be explicitly applied to char.
You can explicitly specify signed char or unsigned char to avoid
ambiguity and ensure consistent behavior across different platforms.
• While unsigned characters have values between 0 and 255,
• signed characters have values from -128 to 127.