/*------------------------------------------------------------------------------ * File: p1.c * Function: Prints out variables according to their Data Type with the size and the ranges of the variables * Description: This C program outputs numbers using * Input: None * Output: " * Author(s): Noah Woodlee * Lab Section: 09 * Date: Aug 20, 2021 *----------------------------------------------------------------------------*/ #include #include #include #include int main() { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer // Printf statements // Header printf("-------------------------------------------------------------------------------------------------------------------\n"); printf("| Data Type | Value | Size (in bytes) | Min | Max |\n"); printf("-------------------------------------------------------------------------------------------------------------------\n"); // signed char char signedChar = 'a'; printf("| signed char | '%c' | %d | %d | %d |\n",signedChar,sizeof(signedChar),SCHAR_MIN,SCHAR_MAX); // short int int shortInt = 12; printf("| short int | %hd | %d | %d | %d |\n",shortInt,sizeof(shortInt),SHRT_MIN,SHRT_MAX); // int int integer = 900; printf("| int | %d | %d | %d | %d |\n",integer,sizeof(integer),INT_MIN,INT_MAX); // long int int longInt = 200; printf("| long int | %hi | %i | %i | %i |\n",longInt,sizeof(longInt),LONG_MIN,LONG_MAX); // long long int int longlongInt = -400; printf("| long long int | %hhi | %d | %d | %d |\n",longlongInt,sizeof(longlongInt),LLONG_MIN,LLONG_MAX); // unsigned char char unsignedChar = 'o'; printf("| unsigned char | '%c' | %d | %lu | %lu |\n",unsignedChar,sizeof(unsignedChar),0,UCHAR_MAX); //unsigned short int int unsignedshortInt = 500; printf("| unsigned short int | %hu | %d | %lu | %lu |\n",unsignedshortInt,sizeof(unsignedshortInt),0,LONG_MAX); //unsigned int int unsignedInt = 500; printf("| unsigned int | %u | %l | %u | %u |\n",unsignedInt,sizeof(unsignedInt),0,LONG_MAX); //unsigned long int int unsignedlongInt = 800; printf("| unsigned long int | %lu | %lu | %u | %ld |\n",unsignedlongInt,sizeof(unsignedlongInt),0,ULONG_MAX); //unsigned long long int int unsignedlonglongInt = 5000; printf("| unsigned long long int | %llu | %llu | %llu | %llu |\n",unsignedlonglongInt,sizeof(unsignedlonglongInt),0,ULLONG_MAX); //float float flo = 50.022; printf("| float | %f | %d | %f | %f |\n",flo,sizeof(flo), 16777215,FLT_MAX); //double double dou = 5506; printf("| double | '%E' | %d | %e | %e |\n",dou,sizeof(dou),DBL_MIN,DBL_MAX); }