There are basically four data types in ‘C’
Using data types helps compiler to set aside space in memory for the variable.
‘Character’ can be signed characters or unsigned characters. Unsigned characters are 8 bits i.e. value of unsigned character can be between 0to 28 i.e. 0 to 255. For signed characters the left-most bit is used to represent the sign. Hence the remaining 7 bits are used for value. Hence value can be between -27 to +27 i.e. -128 to +127.
‘Integers’ can be short integers or long integers. These two provide different lengths of integers. Short is generally 16 bits and long is 32 bits. Integers can be either 16 or 32 bits. The general rule is short <= int <= long. The integers (short as well as long) can be signed or unsigned. Integers are used for fixed-point numbers. Which type of number is required can be decided before hand depending upon the size of data to be stored in the variable.
‘Float’ are used for floating point numbers. Float is a single precision floating point. Float occupies 4 bytes in memory.
‘Double’ which gives double precision floating point occupies 8 bytes. Even if 8 bytes are not sufficient, ‘long double’ which occupies 8 bytes can be used.
When we say
double a, b;
8 bytes for a and 8 bytes for b are set aside in memory and the range of values available also get fixed.
Table of datatypes
The following table gives a summary of all the datatypes, number of bytes assigned to each one and the range of value the variable of that type can take up.(AS per 32 bit machine)
C Related Interview Questions
|DBMS Interview Questions||C++ Interview Questions|
|C & Data Structures Interview Questions||Java Interview Questions|
|Go (programming language) Interview Questions||F Sharp (programming language) Interview Questions|
|C preprocessor Interview Questions||R Programming language Interview Questions|
|D Programming Language Interview Questions||Lua (programming language) Interview Questions|
|Embedded C Interview Questions|
Introduction To C-programming
Data Types And Storage Classes
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.