C Program to print Range of Data Types
Notes:
C Program to print Range of Data Types
The data type also indicates the possible range of values can be stored in a specific type of a variable or a constant
1. int : 4 or 2 bytes : (-32,768 to 32,767 ) or (-2,147,483,648 to 2,147,483,647)
2. float : 4 bytes : 1.2E-38 to 3.4E+38
3. double : 8 bytes : 2.3E-308 to 1.7E+308
4. char : 1 byte : -128 to 127
5. void : 1 or 0 byte : no value or nothing
W.K.T:
1 byte = 8 bits
2 bytes = 16 bits
4 bytes = 32 bits
8 bytes = 64 bits
The data type also indicates the type of operations can be performed on a specific type of data
int, float, double : +, -, *, /, < , > etc.
char : To upper case, To lower case etc.
Example Code:
#include <stdio.h>
#include <limits.h>
#include <float.h>
int main()
{
printf("int min=%i\n",INT_MIN);// =-2147483648
printf("int max=%i\n",INT_MAX);// 2147483647
printf("float min=%e\n",FLT_MIN);// 1.175494e-038
printf("float max=%e\n",FLT_MAX);// 3.402823e+038
printf("double min=%e\n",DBL_MIN);// 2.225074e-308
printf("double max=%e\n",DBL_MAX);// 1.797693e+308
printf("char min=%i\n",CHAR_MIN);// -128
printf("char max=%i\n",CHAR_MAX);//127
printf("float precision=%i\n",FLT_DIG);//6
printf("double precision=%i\n",DBL_DIG);//15
printf("long double precision=%i\n",LDBL_DIG);//18
return 0;
}