C Data Type
In this you will learn basic data types such as int, float, char etc in C programming.
In C programming, data types are declaration of variables. This determines the type and size of data association with variables.
For example :
Here, myVar, is a variable of int (integer) type.The size of int is 4 bytes.
Basic Data_types
Here's a table of containing commonly used types inn C programming for quick access.
Int
Integer are whole numbers that can have both zero, positive and negative but no decimal values.
For example :
we can use int for declaration an integers variables .
int a;
Here, a is a variable of type integers.
You can declare multiple variables at once in C programming.
For example :
int a , age;
The size of int is usually 4 bytes ( 32 bits ). And it can take 2 pow32.
Float and double
float and double are used to hold real numbers.
float salary;
double price;
In C floating-points numbers can also be represent in exponentional.
For example :
float normalization_factor = 22.442e2
What's the difference between float and double?
The size of float ( single precision float data type) is 4 bytes. And double ( double float precision data type ) is 8 bytes.Char
Keyword Char is used for declaring character types variables.For example
char test = 'h' ;
The size of the character variable is 1 byte.
Void
void is an incomplete type. It means "nothing" or " no type". You can think of void as absent.
For example :
If a function is not returning anything, its return type should be void.
Note that you cannot create variable void type.
Short Long
If You need to used a large number,you can use a specifier long. Here's Show below
long a ;
long long b ;
long double c ;
Here, a and b can store integer values. And C can store floating point number.
If you are sure, only a small integer ( -32 , 767 ,+32 , -767 range) will be used, you can use short.
short b ;
You can always check the size of variable using the size of() operator.
Signed and unsigned
In C sign and unsigned are the modifiers. You can alter the data Storage of data type by using them.
For example :
unsigned int x ;
int y ;
Here, the variable x can hold only zero and positive values because we have used unsigned modifiers.
Considering the size of int is 4 bytes, variable y can hold values from -2pow31 to -2pow31 -1, Where variable x can hold values from 0 to 2pow32 -1
Other data_types in C programming are :
- bool type
- Enumerated type
- complex type
Derived Datatypes
Datatypes that are derived from fundamental datatypes are derived types.For example :
array, pointer., function types, structures etc.
0 comments:
Post a Comment