CS211 Homework 1

This is a “hello world” assignment that is simply meant to acclimate you to the process of testing homeworks in the class. You are being asked to write a small program that has three features:

You program must be named “hw1.c”, and it must have a comment block at the top, that looks something like this:

/*
 * Author: your name
 * Netid: your netid
 * Aid: If in doubt, list anything you referenced. A stack overflow post, chatgpt, gemini, your friend Bob, etc. If referring to an LLM, you must included a link to a particular session. Just saying "I asked chatgpt" isn't a get out of trouble free statement. If two submissions are nearly identical and nothing is listed, I will have to assume that there was copying with an attempt at obfuscation.
 */

I don’t expect you to need to reference anything for this assignment, and I won’t check for identical code since this is so short (< 20 lines). You will need to use an if statement to see if there is a second argument. The syntax is nearly the same as in java, with a boolean expression in parenthesis following the if and then a single statement or compound statement. I always use a compound statement, with curly braces, to remove ambiguity. For example:

if (argc == 27) {
    printf("There are 27 arguments! Wow!\n");
}

Some examples:

Compile your code with: gcc hw1.c -o hw1

$ ./hw1
Hello World
$ ./hw1 Bob
Hello Bob
$ echo $?
22

Testing

You are provided with a testing script named “test_hw1.sh”. Put this script into the same directory as your hw1.c file and run it with the command: bash test_hw1.sh. It will run, test for errors, and print out your score. This will work on the ilab machines, but I cannot guarantee that it will work on your personal computer.

Submission

You should submit your hw1.c file through Canvas.