ECE 8473 - Assignment #1 - Due: 22 Sept 2022


Upload source files - individual files or archive (e.g. zip, tar) - to your osp/a1 upload area.

Programs must compile with no warnings or errors using:

  gcc -std=c11 -pedantic -Wall
Each source file must start with a comment containing your name and a description.

References: printf format list; limits.h, float.h, errno.h, perror, tgmath.h, time.h


  1. a1/p1.c - limits.h

    Write a C program which displays the names and values of the following constants from limits.h:

      CHAR_BIT, CHAR_MIN, CHAR_MAX, SCHAR_MIN, SCHAR_MAX, UCHAR_MAX
    
      SHRT_MIN, SHRT_MAX, USHRT_MAX
    
      INT_MIN, INT_MAX, UINT_MAX
    
      LONG_MIN, LONG_MAX, ULONG_MAX
    
      LLONG_MIN, LLONG_MAX, ULLONG_MAX 
    
    and also computes at run-time (without using any predefined constants or assumptions) and displays the value of UCHAR_MAX.
  2. a1/p2.c - float.h

    Write a C program which displays the names and values of the following constants from float.h:

      FLT_MIN, FLT_TRUE_MIN, FLT_MAX, FLT_EPSILON
    
      DBL_MIN, DBL_TRUE_MIN, DBL_MAX, DBL_EPSILON
    
      LDBL_MIN, LDBL_TRUE_MIN, LDBL_MAX, LDBL_EPSILON
    
    and also displays the values of DBL_TRUE_MIN/2, stored in an double variable, and DBL_MAX*2, stored in a double variable.
  3. a1/p3.c - sqrt(-1)

    Write a C program which computes and displays the value of sqrt(-1). Include <errno.h> and after calling sqrt() display the value of errno and also call perror().

    Also compute and display the value of some tgmath.h function (your choice) with a valid input which produces a range error, i.e. overflow. Display the value of errno and also call perror().


  4. a1/p4.c - 32-bit Year 2038 Problem

    Write a C program which displays the argument and result values of ctime() from time.h for the following argument values:

      INT_MAX-1
      INT_MAX
      INT_MAX+1
      0
      -1
      INT_MIN
    
    Note that computing INT_MAX+1 requires use of a data type larger than int, e.g. long long.

    If you can, compile in 32-bit mode using gcc -m32 option to see the problem.