Pejman Moghadam / C-programming

C - short int data type (identical to short)

Public domain


#include <stdio.h>
#include <limits.h>

int main()
{
    short int i;

    i=32000;
    fprintf(stdout, "This is a 'short int' number : %hd\n", i);
    fprintf(stdout, "Number of bits in a 'short int' type : %d\n", sizeof(short int) * 8 );
    fprintf(stdout, "Minimum and maximum values a 'signed short int' can hold : %hd %hd \n",
            SHRT_MIN, SHRT_MAX);
    fprintf(stdout, "Minimum and maximum values an 'unsigned short int' can hold : 0 %u \n",
            USHRT_MAX);
    return 0;
}

--Output--

This is a 'short int' number : 32000
Number of bits in a 'short int' type : 16
Minimum and maximum values a 'signed short int' can hold : -32768 32767
Minimum and maximum values an 'unsigned short int' can hold : 0 65535

BY: Pejman Moghadam
TAG: c, data-type
DATE: 2011-02-28 17:31:00


Pejman Moghadam / C-programming [ TXT ]