Program to print the range of data types in c

//Program to print the range of data types in c
#include<stdio.h>
#include<conio.h>
#include<limits.h>
int main()
{
clrscr();
printf("int %%d %d %d to %d",
sizeof(int),INT_MIN,INT_MAX);
printf("\nchar %%d %d %d to %d",
sizeof(char),CHAR_MIN,CHAR_MAX);
printf("\nlong %%d %d %d to %d",
sizeof(long),LONG_MIN,LONG_MAX);
printf("\nshort char %%d %d %d to %d",
sizeof(short char),SCHAR_MIN,SCHAR_MAX);
printf("\nint %%d %d %d to %d",
sizeof(short),SHRT_MIN,SHRT_MAX);
getch();
return 0;

}

8 comments:

  1. what about the unsigned int, float, char..etc how to print there range...??

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. for float we need to include other headerfile: float.h

    for minimum float value: FLT_MIN
    for maximum float value: FLT_MAX

    example:

    #include"stdio.h"
    #include"float.h"

    int main()
    {

    printf("Minimum value for float is: %e", FLT_MIN);
    printf("Maximum value for float is: %e", FLT_MAX);

    return 0;
    }

    ReplyDelete
  5. for float we need to include other headerfile: float.h

    for minimum float value: FLT_MIN
    for maximum float value: FLT_MAX

    example:

    #include"stdio.h"
    #include"float.h"

    int main()
    {

    printf("Minimum value for float is: %e", FLT_MIN);
    printf("Maximum value for float is: %e", FLT_MAX);

    return 0;
    }

    ReplyDelete