C Programming Homework #1: Hello World!

Due: Friday, January 22, 2016

This assignment is about getting familiar with the programming environment we'll be using. It entails a lot of reading and tinkering but no real programming (we'll get to that next week!)

Lesson #1, Lesson #2, and Lesson #3 all cover the basics of using Unix. You should read or at least skim them. Use those lessons as a reference for the future. Lesson #4 contains the basic "Hello, World" program you'll be experimenting with in this assignment.

  1. Be sure you can get logged into Lemuria either from your own computer or from a lab machine (or both).

  2. Use a text editor such as nano (or any other editor on the system) to create a text file. Enter a few lines of text into the file (it doesn't matter what) and experiment with the text editor's features. Be sure you save your modified file before exiting the text editor.

  3. Experiment with the following Unix commands:

      $ ls
      $ ls -l
      $ cp source_file destination_file
      $ less file_name
      $ mv old_name new_name
      $ rm file_name
    

    For example, copy the file you created above to make a second file with a different name. View the copy with less. Rename one of the copies using mv. Remove the extra files with rm. The exact steps you follow aren't important. The goal is to get familiar with these basic file management commands.

  4. Enter the "Hello, World!" program in Lesson #4 into a file named hello.c. Compile the program with a command such as:

      $ gcc -Wall -o hello hello.c
    

    The -Wall option turns on all warnings. I recommend using it (although technically it is not necessary). The -o option specifies that the name of the executable file immediately follows on the command line (hello in this case). The name of the file being compiled is at the end of the command line.

  5. Introduce a few errors in the file (one at a time) to see what the error messages look like when you try to compile it again. Try removing a semicolon or a parenthesis or a quotation mark. Try spelling main wrong. Leave your file with a single error and add a comment specifying the error message. Also be sure your name is at the top of the file (in a comment).

There isn't much to turn in for this assignment. However, I would like you to submit (on Moodle) your file with the error and the comment described above. This will give you an opportunity to practice transferring a file from Lemuria to your Windows system (you can mail it to yourself from Lemuria or use the pscp program).


Last Revised: 2016-01-17
© Copyright 2016 by Peter C. Chapin <PChapin@vtc.vsc.edu>