The Data what be store can be classify as follows.
--> Variable is just a memory location which is capable of storing some data.
--> Datatype represent characteristic properties of a variable i.e the type of value to store and the amount of memory required.
--> So, the datatype provides a "C" language are as follows.
1) char (1 byte)
2) int (2 bytes)
3) float (4 bytes)
4) double (8 bytes)
--> The Keywords short, long, signed, unsigned are referred as Type Qualifiers. Because they specify/qualify the properties of datatype.
--> The Keywords short, long are in general referred as Size Qualifiers.
--> The Keywords signed, unsigned are referred as Sign Qualifiers.
--> When we don't specify any qualifiers, then by default it is considered as short and signed.
signed char ( 1 byte ):
1 | 1 | 1 | 1 | 1 | 1 | 1 |
MSB <---- 7 6 5 4 3 2 1 0 ---->LSB
Range: -128 to +127
unsigned char( 1 byte ):
Range: 0 to 255
--> When we have n bits, the range of signed type will be -2n-1 to +2n-1-1 and for unsigned type will be 0 to 2n-1
Example:-
signed char ---> 8 bits ---> -27 to +27-1
---> -128 to +127
unsigned char ----> 8 bits ---> 0 to 28-1
0 to 255
short signed int ----> 2 bytes ---> 16 bits ---> -215 to 215-1
-32768 to 32767
short unsigned int ----> 2 bytes ---> 16 bits ---> 0 to 216-1
0 to 65535
long signed int ----> 4 bytes ---> 32 bits ---> -231 to 231-1
-2147483648 to 2147483647
long unsigned int ---> 4 bytes ---> 32 bits ---> 0 to 232 -1
0 to 4294967296
float ( 4 bytes):
Here the data will be stored in Mantissa and Exponent format.
--> Here we can store a maximum of 6 digits only in the functional part.
--> Similarly double type required 8 bytes.
--> Memory will not be allocated for a datatype.
--> Memory will allocated only for a variable.
--> So, we can't stored data in a datatype, but we can store data only in a variable
--> A Variable can't be access unless we declare it.
--> The syntax for declaring a variable is as follows.
datatype <variable name> [= value]
--> When we declare a variable, memory will be allocated for the corresponding number of bytes and initially it contains some dummy value and is referred as garbage value.
Example:- Declaration:
---> We can also specify the value to be placed in a variable at the time of declaration itself and it is referred as initialization.
Example:- Initialization:
---> The value contained in a variable can be changed/modified as required the assigning the necessary value and it is referred as assignment
Example:- Assignment:
---> When we are required to display a direct value or the value contained in a variable or the result contained in a variable or the result of an expression, we should specify the type specifiers in the format.
---> Some of the type specifiers are as follows.
%c ---------> Character
%i (or) %d ---------> integer
%f ---------> float
%g ---------> double
%li (or) %ld ---------> long integer
%lf ---------> long float
%lg ---------> long double
%u ---------> unsigned
---> The symbol % represents unknown value or blank, which will be filled later
---> The symbol next do % specify the type of value to be filled in that blank
---> The value to be filled in that blank should be specified after the format.
Example:-
#include<stdio.h>
#include<conio.h>
void main( )
{
int x;
x = 56;
printf("%i", x);
}
Output:-
56
---> The output is to be displayed in the most possible stylish way.
0 comments:
Post a Comment