Reading Basic Inputs Lab

  1. In a previous lab you wrote code and saved it in a file quarts.c which calculated the number of liters from a given number of gallons, quarts, and pints. Revise this code to ask the user to input the number of gallons, quarts, and pints. The outcome should be the same (printing the number of liters).

    It's probably a good idea to save this code to a new file, rather than editing the old file (just in case you would like to revisit it later). Also remember to acknowledge your previous lab partner(s) as authors when you copy and revise code.

  2. Write a program that accepts a date from the user in the form mm/dd/yyyy and then displays it in the form yyyymmdd. Below shows an example of the prompt the user should see on the terminal.

    
    Enter a date (mm/dd/yyyy): 2/17/2011
    You entered the date 20110217
    
    Save your program in a file named format-date.c
  3. Write a program that asks the user to enter the numbers from 1 to 16 (in any order) and then displays the numbers in a 4 by 4 arrangement, followed by the sums of the rows, columns, and diagonals.

    
    Enter the numbers from 1 to 16 in any order:
    16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1
    
    16  3  2 13
     5 10 11  8
     9  6  7 12
     4 15 14  1
    
    Row sums: 34 34 34 34
    Column sums: 34 34 34 34
    Diagonal sums: 34 34
    
    If the row, column, and diagonal sums are all the same (as they are in the example above), the numbers are said to form a magic square. The magic square shown here appears in a 1514 engraving by artist and mathematician Albrecht Durer. Save your program in a file called magic-square.c

Lab Report 2 Submission

For this lab submission, please submit two files to gradescope: magic-square.c and format-date.c Be sure to review the Guidelines for submitting work. Make sure you have:

  1. Identified all authors who contributed to the program
  2. Included an Academic Honesty Statement at the top of the program file.
  3. Documented each function (except for main).
  4. Included comments within main to describe what you are doing.

Note: there is no autograder for this program.