12.07.2015 Views

Programski jezik C - Pmf

Programski jezik C - Pmf

Programski jezik C - Pmf

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.4. OSNOVNI TIPOVI PODATAKA 51Ovdje imamo primjer računala na kojem tip short zauzima 2 okteta, tip int4 okteat, a tip long 8 okteta. Stoga imamo sljedeće raspone:• unsigned short: 0,1,. . . , 2 16 − 1 = 65535,• short: −2 15 = −32768,. . . , -1,0,1,. . . , 2 15 − 1 = 32767,• unsigned: 0,1,. . . , 2 32 − 1 = 4294967295,• int: −2 31 = −2147483648,. . . , -1,0,1,. . . , 2 31 − 1 = 2147483647,• unsigned long: 0,1,. . . , 2 64 − 1 = 18446744073709551615,• long: −2 63 ,. . . , -1,0,1,. . . , 2 63 − 1.Na vašem računalu ovi rasponi mogu biti drugačiji. Sljedeći program ispisujegornje vrijednosti:#include #include int main(){short s_max = SHRT_MAX;short s_min = SHRT_MIN;unsigned short us_max = USHRT_MAX;int i_max = INT_MAX;int i_min = INT_MIN;unsigned ui_max = UINT_MAX;long l_max = LONG_MAX;long l_min = LONG_MIN;unsigned long x_max = ULONG_MAX;}printf("SHRT_MAX = %hd\n",s_max);printf("SHRT_MIN = %hd\n",s_min);printf("USHRT_MAX = %hu\n",us_max);printf("INT_MAX = %d\n",i_max);printf("INT_MIN = %d\n",i_min);printf("UINT_MAX = %u\n",ui_max);printf("LONG_MAX = %ld\n",l_max);printf("LONG_MIN = %ld\n",l_min);printf("ULONG_MAX = %lu\n",x_max);return 0;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!