Practice Assignment

(squares1.c)

Information

  1. Write a program that prints out the numbers 1 to 20 and also the numbers squared. It should look like this:
       Value     Value*Value
    ------------------------
         1:           1
         2:           4
         3:           9
         4:          16
         5:          25
         6:          36
         7:          49
         8:          64
         9:          81
        10:         100
        11:         121
        12:         144
        13:         169
        14:         196
        15:         225
        16:         256
        17:         289
        18:         324
        19:         361
        20:         400
    
    Notice that all of the numbers are right-justified. Each number in the first column takes up 6 characters, and each number in the second column takes up 12 characters. Your output must match exactly. Don't forget the colon after the number in the first column.

    Approximate number of lines of code: 6.

    The name of the file should be squares1.c and the command to compile it will look like this:

    gcc -Werror -Wall -Wextra -ansi -pedantic squares1.c -o squares1 -O2 -Wno-unused-result
    
    output-squares1.txt

Notes