Range of data types :
Data type Bytes in Ram Range of data typechar 1 bytes -128 to 127
int 2 bytes -32, 768 to 32,767
float 4 bytes 3.4c-38 to 3.4 c+ 38
double 8 bytes 1.7C – 308 to 1.7c +308
Integer Types : Integers are whole numbers with a range of variables supported by a particular machine.
In a signed integer uses one bit for sign and 15 bits for magnitude
C has three classes of integer storage
short int
1. int
2. long int
It has a set of qualifiers i.e.,
1. sign qualifier
2. unsigned qualifier
short int uses half the range of storage amount of data, unsigned int use all the bits for the magnitude of the number and are positive.
Datatype Size Range
char or signed char 1 byte -128 to 127
unsigned char 1 byte 0 to 255
int or signed int 2 byte -32,768 to 32, 767
unsigned int 2 bytes 0 to 65535
Floating Point Datatype:
Floating Point numbers are stored with 6 digits of precision. Those are defined with keyword float. When the accuracy is not sufficient then the datatype double can be used. double gives a precesion of 14 digits these known as double precesion numbers.
Still for a better process we can use long double which uses 80 bits.
Character Datatype : Character are usually stored in 8 bits
Void datatype : A void type has no value this is usually used to specify the return type of function , this function does not return any value to calling function
Declaration of Variable :
It tells the complier what the variable name is used, what type of date is held by the variable.
Syn: datetype v1,v2,….vn;
Eg : int a, b;
float sum;
double ratio;
representation of Constant:
const int r = 10;
Assigning values to variables:
Eg : int x,y;
x= 10;
y=5;
Type def : Defined as type definition by using typedef we can create new datatype.
Typedef type data _ame;
Type ---- datatype
Dataname---- Name of that type.
Programs : Program for variable declaration
main( )
{
float x,p;
x=10.1;
p=5.2;
printf (“x = %f”, x);
printf (“p = %f”, p);
}
O/P :
x= 10.10000
p = 5.2
Type def program :
# include < stdio.h>
main ( )
{
typedef int amt ;
amt Rupees = 20;
printf (“ Rupees %d“, Rupees);
}
Output :
Rupees 20.
0 comments:
Post a Comment