Limits.h Library

Share it Please
Limits.h library is used to get the maximum and minimum limits of any datatypes. it means that the upper and the lower limits of any datatype can't be breaked. suppose the maximum limit of short in is 32767 so we can't store the value greater then this in short int datatype. let us see macros and its uses with how to use.

Macro ValueExplaination
CHAR_BIT 8Shows the number of bits in one byte
INT_MIN -32767Minimum value of int datatype.
UINT_MAX65535Maximum value of unsigned int datatype.
SCHAR_MIN -127Minimum value of char datatype.
SCHAR_MAX +127Maximum value of char datatype.
UCHAR_MAX 255Maximum value of unsigned char datatype.
SHRT_MIN -32767Minimum value of short int datatype.
SHRT_MAX +32767Maximum value of short int datatype.
USHRT_MAX 65535Maximum value of unsigned short int datatype.
LONG_MIN -2147483647Minimum value of long int datatype.
Macro +2147483647Maximum value of long int datatype.
ULONG_MAX +4294967295Maximum value of Unsigned long datatype.
NOW LET US SEE EXAMPLE PROGRAM FOR THIS LIBRARY.

PROGRAM:

#include<stdio.h>
#include<conio.h>
#include<limits.h>
main()
{
    clrscr();
    printf("The minimum value of CHAR is %d\n", CHAR_MIN);

    printf("The maximum value of CHAR is %d\n", CHAR_MAX);

    printf("The minimum value of SIGNED CHAR is %d\n", SCHAR_MIN);

    printf("The maximum value of SIGNED CHAR is %d\n", SCHAR_MAX);

    printf("The maximum value of UNSIGNED CHAR is %d\n", UCHAR_MAX);

    printf("The minimum value of SHORT INT is %d\n", SHRT_MIN);

    printf("The maximum value of SHORT INT is %d\n", SHRT_MAX);

    printf("The minimum value of INT is %d\n", INT_MIN);

    printf("The maximum value of INT is %d\n", INT_MAX);

    printf("The minimum value of LONG is %ld\n", LONG_MIN);

    printf("The maximum value of LONG is %ld\n", LONG_MAX);

    printf("The number of bits in a byte is %d\n", CHAR_BIT);

    getch();

    return(0);
}