- A data type specify type of the data type
- Data types are require storing different type of value for operation purpose.
- C- Language has the following basic data types.
[1] int (Integer):
- Integer data type is used to store integer value without having fractional part.
- “int” keyword is used to define integer data type variable.
- It allocated 2 byte of memory space.
- Example: 10,5, 25, 100,-50
[2] char (Character):
- Character data type is used to store character data.
- 1 byte of memory space is allocated to char data type variable.
- “char” keyword is used to declare character data type variable.
- It can store a signal character in 1 byte of memory space.
- Example: ‘a’, ‘10’, ‘hello’, ‘123’
[3] float:
- A float data type is used to store numerical value with fractional part.
- “float” keyword is use to declare float data type variable.
- 4 byte of memory space is allocated to it.
- It may store positive or negative value.
- Example:5, -0.025, 25.075
[4] double:
- Double data type is also use to store numerical value with fractional part
- Normally, float data type is use only for simple business calculations as it does not provide higher level of accuracy.
- For complex calculation such as scientific or engineering were more higher level of accuracy is require, we can use double data type.
- 8-byte of memory space is allocated to it.
- We can use “double” keyword to declare double data type variable.
[5] long:
- long data type is similar to double data type.
- It offers higher level of accuracy.
- “long”keyword is use to declare long data type variable.
Data type | Range |
Char | 128 to -127 |
Int | 32767 to -32766 |
Float | 3.4e.38 to -3.4e.37 |
Double | 1.7e.308 to -1.7e.307 |
Variable (Identifier)
- A variable is a named memory area that stores (holds) value.
- A variable may change its value during the program execution.
- Variable should have meaning full name.
- they are defined using data types
- They must follow the following naming convention rules:
Naming Convention Rules(Identifier rules):
- First letter must be alphabet.
- It should not be any keyword or reserved word.
- It can be up to 32 characters long.
- It should not contain any white space. We can use underscore (-) to join two words.
- Name must be meaning full.