CSc 3320: System Level Programming, homework 1

As you are aware, we have lab assignments due every week. We also will have several homework assignments this semester, and this is the first. While the labs are directed, the homework assignments present larger problems that you should break down into smaller problems. You should spend some time thinking about and planning your homework solutions before coding them.

Program Description

In this assignment, you are to create C program to display song lyrics in a random order. Prompt the user to enter an integer number, then randomly display a line from a song, and repeat this according to the integer. That is, if the user enters 4, display 4 lines of lyrics.

Choose a song with at least 10 lines of lyrics, and be sure to include the artist's name, song name, and (if applicable) album name in comments in your program. You are welcome to choose a song that you like, though keep in mind that we will grade it, so if the lyrics contain words that you would not say in front of your parents, you should find another song.

To keep things simple, you can hard-code the lyrics. That is, you can put each line of lyrics into its own printf statement. Then randomly choose which printf statement is called. Since the lines are printed at random, it should be different every time.

The lyrics do not have to be accurate. Feel free to use "misheard" song lyrics. For example, many people think Taylor Swift is saying "All the lonely Starbucks lovers" in her "Blank Space" song.

Here's an example of what the output might look like:

cascade:~> gcc hmwk1_mweeks.c -o hmwk1_mweeks
cascade:~> ./hmwk1_mweeks
Enter an integer: 4
Well, everybody's talking about the bird!
Oom oom oom oom, ooma mow mow
A well a bird
B-b-b aah, aah!
cascade:~> ./hmwk1_mweeks
Enter an integer: 4
Pa pa pa pa, pa pa pa pa, pa pa pa pa
A well a bird
Surfin' bird
A well a don't you know about the bird?
cascade:~>

Each run of the program should give somewhat different output.

Notes:

Click here for a script that shows the contents of several C programs, along with compilation, and example runs. This shows input and output, a for loop, a switch statement, and how you can get a random number.

  1. script hmwk1_XX.log

  2. This command starts recording all the things you type and the responses from the system. "hmwk1_XX.log" is just the name of the file it creates. It is a good idea for you to keep backup copies of your program, i.e. "hmwk1_XX.c" is obviously the first assignment. Also note that we use ".c" as our file's extension.
  3. cat hmwk1_XX.c

  4. Shows the contents of the file. You may want to include other relevant commands, such as "ls -l", which gives a file list.
  5. gcc hmwk1_XX.c -o hmwk1_XX

  6. Compiles it.
  7. ./hmwk1_XX

  8. Runs your program. Be sure to try enough test cases to be sure that it works.
  9. exit
    This command ends the recording of the things you type/system responses. You can now view "hmwk1.log"
  10. Clean up the log file, and call the cleaned-up version hmwk1_XX.txt. Make sure it does not have any extraneous characters, and is a plain text file (no proprietary formats). It should be in a mono-spaced font, though if you saved it as a plain text file, this is not a concern. Submit this and your hmwk1_XX.c file to the grader through the iCollege folder.

Make sure it has all of the relevant information on it, such as your name, the source code, the compilation, and runs of your program.