In this article Data type in C we give the information about fundamental data type in C like int, char, float, double and void.
Data Type in C:
C language is huge & more in its data types.
There are three types of data types supported by ANSI C.
1. Primary data types.
2. Derived data types.
3. User-defined data types
All C compilers mostly support or handled five fundamental data types, namely integer (int), character (char), floating point (float), double-precision floating point (double) and void.
|Data Type||Keyword||Bytes Required||Range||Format|
|Character(Signed)||char||1||-128 to +128||%c|
|Integer(signed)||int||2||-32768 to +32767||%d|
|Float(signed)||float||4||-3.8e38 to +3.4e38||%f|
|Double||double||8||-1.7e308 to +1.7e308||%lf|
|Long integer (signed)||long||4||2,147,483,648 to 2,147,438,647||%ld|
|Character(unsigned)||Unsigned char||1||0 to 255||%c|
|Integer (Unsigned)||Unsigned int||2||0 to 65535||%u|
|Unsigned long integer||Unsigned long||4||0 to 4,294,967,295||%iu|
|Long double||Long double||10||-1.7e932 to +1.7e932||%Lf|
Variable in C:-
Definition:- “A variable is a data name that may be used to store a data value.”
- An important benefit of the variable is take different values at different times during execution.
- A variable name can be select by the programmer in a meaningful way so the advantages of variable as to reflect its function or nature in the program.
Rules for Declaring Variables:-
- Variable names consist only letters, digits and the underscore(_) character.
- They must begin with a letter but some situation or systems permit underscore as the first character.
- Length should not be normally more than eight characters.
- Uppercase and lowercase are significant. that is, the variable Sum is not same as total or SUM
- It should not be a keyword.
- White space is not allowed.
Some examples of valid variable names are: Rajveer, rahul, neeta, n1, tot, Sum_num etc.
Invalid examples include: 123, % , char, 25th etc.
Declare Variable in C:
Ex. int n1;
Initialize variable in C:
data_type variable_name= value;
Ex. int n1=10;