Lab 1: Linux, C Basics, and Make

Due by the end of class

Linux

It is expected that you become familiar with the Linux command line environment in this course. If you are new to Linux, you might want to check out the Linux tutorial below. Feel free to come back to it if you have issues later.

Stars

Write a program that prints out 10 lines of asterisks (*). There should be one asterisk on the first line, two on the second, three on the third, and so on. The final output should be as follows.

*
**
***
****
*****
******
*******
********
*********
**********

Sure, you could copy and paste those asterisks into printf() calls, but that would be boring (and lose you points). Use two for loops to print out the asterisks.

You should compile your program using the command-line compiler gcc, and you should have gcc create an executable named stars. This information should also be included in your makefile, described below.

Make

GNU Make is a standard utility used to generate an executable program from a set of source files. A makefile defines the set of rules necessary to build the executable from the source. Please read my tutorial:

Here is an outside tutorial if you'd prefer that:

Now that you know how to create a makefile, create a makefile (called makefile, as is standard) whose default rule is stars. The dependency of stars is whatever the name of your .c file is. The action is compiling that file with gcc, using the -o flag to name the output file stars.

Add a clean rule that removes stars using the rm command.

Turn In

Zip the contents of your lab directory, including the makefile and the source C file. Upload this zip file to Brightspace. Do not include any object files or executables. Running the make command must compile the required C source code file and generate an executable named stars.

All work must be done individually. Never look at someone else's code. Please refer to the course policies if you have any questions about academic integrity. If you have trouble with the assignment, I am always available for assistance.