My program is just printing ranges but the unsigned integer is not working. The max is suppose to be 65535. And also integer is messed up. And also long is. I'm new to programming and books can be vague.
C:\Documents and Settings\Mikes\ Desktop\Cprog>g cc Datatypes.c -o Datatypes.exe
C:\Documents and Settings\Mikes\ Desktop\Cprog>D atatypes
Character min: -128
Character max: 127
Integer min: -2147483648
Integer max: 2147483647
Long min: -2147483648
Long max: -2147483648
Short min: -32768
Short max: 32767
Signed Character min: -128
Signed Character max: 127
Unsigned Character max: 255
Unsigned Integer max: 4294967295
Unsigned Long max: 4294967295
Unsigned Short max: 65535
C:\Documents and Settings\Mikes\ Desktop\Cprog>
C:\Documents and Settings\Mikes\ Desktop\Cprog>g cc Datatypes.c -o Datatypes.exe
C:\Documents and Settings\Mikes\ Desktop\Cprog>D atatypes
Character min: -128
Character max: 127
Integer min: -2147483648
Integer max: 2147483647
Long min: -2147483648
Long max: -2147483648
Short min: -32768
Short max: 32767
Signed Character min: -128
Signed Character max: 127
Unsigned Character max: 255
Unsigned Integer max: 4294967295
Unsigned Long max: 4294967295
Unsigned Short max: 65535
C:\Documents and Settings\Mikes\ Desktop\Cprog>
Code:
#include<stdio.h>
#include<limits.h>
#include<float.h>
main()
{
/* A program to determine the range of data types */
printf("Character min: %d\n\n", CHAR_MIN);
printf("Character max: %d\n\n", CHAR_MAX);
printf("Integer min: %d\n\n", INT_MIN);
printf("Integer max: %d\n\n", INT_MAX);
printf("Long min: %d\n\n", LONG_MIN);
printf("Long max: %d\n\n", INT_MIN);
printf("Short min: %d\n\n", SHRT_MIN);
printf("Short max: %d\n\n", SHRT_MAX);
printf("Signed Character min: %d\n\n", SCHAR_MIN);
printf("Signed Character max: %d\n\n", SCHAR_MAX);
printf("Unsigned Character max: %d\n\n", UCHAR_MAX);
printf("Unsigned Integer max: %u\n\n", UINT_MAX);
printf("Unsigned Long max: %lu\n\n", ULONG_MAX);
printf("Unsigned Short max: %d\n\n", USHRT_MAX);}
Comment