Wednesday 12 August 2015

C Program to print Data Type Size and Ranges


Program:

#include< stdio.h >
#include< conio.h >
#include< limits.h >
#include< float.h >
void main( )
{
            clrscr( ); // Clear the screen Contents
            printf("Integer data type:\n\tSize: %d\n\tRange: %d to %d", sizeof(int), INT_MIN, INT_MAX);
            printf("\nCharacter data type:\n\tSize: %d\n\tRange: %d to %d", sizeof(char), CHAR_MIN, CHAR_MAX);
            printf("\nFloat data type:\n\tSize: %d\n\tRange: %E to %E", sizeof(float), FLT_MIN, FLT_MAX);
            printf("\nDouble data type:\n\tSize: %d\n\tRange: %E to %E", sizeof(double), DBL_MIN, DBL_MAX);
}

Output:

Integer data type:
           Size: 2
           Range: -32768 to 32767
Character data type:
           Size: 1
           Range: -128 to 127
Float data type:
           Size: 4
           Range: 1.17549E - 38 to 3.402823E + 38
Double data type:
           Size: 8
           Range: 2.225074E - 308 to 1.797693E + 308



0 comments:

Post a Comment