Week 01 Tutorial Sample Answers

  1. Introduce yourselves, get to know your classmates - Why do they want to study computing? What do they want to learn from this course?
    Answered in tute.
  2. Get to know your tutor - How long have they been at UNSW? What are they studying? How can you get in contact with them?
    Answered in tute.
  3. Do you have any questions about the course so far? eg course website, structure, assessments
    See the course outline for details.
  4. Is it OK to ask a really really basic question on the course forum?
    Yes, definitely - that's what the forum is for.

    Ask anonymously if you are shy - but very likely other students want the same questions answered.

  5. I have a brain the size of a planet and been writing C programs since pre-school - do I need to read the course forum?
    Yes - useful information about running of COMP1511 will appear in the course forum - e.g. clarification of assignment specifications.

    If you are on top of the course materials, you should try answering forum questions.

    This will improve your communication skills and often explaining a topic improves your understanding of it too.

  6. How do you make a peanut-butter sandwich?

    How could you break that process into steps?

    How could you break it down clearly enough that a computer could understand it?

    Maybe your tutor could do a live demonstration of following your exact instructions...

    Computers are very literal, and you need to tell them *exactly* what to do, without assuming they know what anything means.

    For example: "take the peanut butter, and put it on the bread" could mean "pick up the jar of peanut butter and put it on top of the bag of bread".

    You need to be very explicit about every step, eg:

    1. Take a jar of peanut butter.
    2. Remove the lid from the jar by unscrewing it, and place it on the table next to you.
    3. Carefully open the bag of bread, without damaging the bread inside, and remove two slices of bread.
    4. Place the bread on the table next to you, lying flat.
    5. Take a butterknife, hold it by the handle, and put it into the jar of peanut butter.
    6. Carefully move the knife through the peanut butter to scoop up approximately a metric teaspoon of peanut butter, and then carefully spread it over one face of the bread, ensuring that the peanut butter is spread evenly and that you don't tear the bread.
    ... and so on.
  7. What is an operating system?

    What operating systems do your classmates run? The tute room? The CSE lab computers?

    What are the differences between each of the various operating systems? What differences are there in their interfaces, and how do you interact with them?

    What are some different ways in which you can interact with a computer?

    What are the differences between graphical user interfaces and the command line? When might one be better than the other?

    An operating system (OS) is a series of computer programs (software) that runs on your computer.

    It's main function is to manage the running of the computer (keeping things like your mouse and keyboard accessible and keeping hardware drivers up to date) as well as providing an interface for programs to run.

    For us in COMP1511, we'll be accessing some of the capability of the operating system when we ask our computer to run our programs.

    Common operating systems are Microsoft Windows, Apple OSX and many versions of UNIX/Linux.

    In terms of interaction, most operating systems can either use a GUI (Graphical User Interface) which allows us to interact mostly with a mouse/touchpad and visual elements. Most OSes also provide a command line terminal, which allows access purely via text.

    A GUI is usually much more user friendly, especially when the user doesn't have much familiarity with computers.

    A command line can, for expert users, be much more efficient than a GUI.

  8. In an ideal world we'd have the first COMP1511 lecture of the week before the first tutorial of the week.

    As we only have 10 weeks of teaching, we don't want to lose one just because it's before the first lecture.

    This means if you have a tut-lab on Monday, you haven't had the lecture the following questions talk about.

    Even without the first lecture, Tutorials and Labs are still worth having because you get to meet and know your tutor, your fellow students and see the lab environment.

    For tutorials before the first lecture - tutors will try to explain what they can as part of the tutorial but don't worry if you don't understand lots of things.

    Of course there are no marks for the week 1 tut-lab.

    If you have a chance to watch it, here's a video of last year's first lecture:

    A video of the 2019 term 3 COMP1511 lecture But if you can't watch the video don't worry.
    Discuss the following features of the sample program from lectures:

    // Basic Hello World program
    // Marc Chee, June 2019
    
    #include <stdio.h>
    
    int main (void) {
        printf("Hello World\n");
        return 0;
    }
    
    • the \n
      It outputs a newline at the end of the line, following the character sequence I love COMP1511, starting the next line of output at the beginning of a new line on the terminal window. It is known as the newline escape sequence.
    • Comments: What should go in a comment? What makes a good comment? How do comments improve program style?

      The comment in the example, is a header comment. You should make sure you have a header comment with your name, date and the purpose of your program at the top of every program you write. Comments can also be added throughout your code to make it easier for a human to understand your program.

    • Indenting and whitespace: What is indented in the sample program? Suggest why.
      The code inside the main function block- in between the braces { and } is indented. This is to help humans understand that indented code is inside a set of brackets.

      White space is required between C language keywords. For instance you can't have intmain without any intermediate space. Statements are placed on separate lines. Additional blanks lines can be inserted to enhance readability (ie. between printf and return). The closing brace } in this example is aligned beneath the type declaration (int) for the main function, to clearly denote the end of the function block.

  9. Write a C program, face0.c, that behaves as follows:
    ./face0
    ~ ~
    0 0
     o
     -
    
    
    Sample solution for face0.c
    #include <stdio.h>
    
    int main(void) {
    
        printf("~ ~\n");
        printf("0 0\n");
        printf(" o\n");
        printf(" -\n");
    
        return 0;
    }
    
    How would you compile this program?
    dcc -o face face.c
    
    How could we modify it to make a program, face1.c, look like this instead?
    ./face1
    ~ ~
    0 0
     o
    \_/
    
    
    Sample solution for face1.c
    #include <stdio.h>
    
    int main(void) {
    
        printf("~   ~\n");
        printf("0   0\n");
        printf("  o\n");
        printf(" \\_/\n");
    
        return 0;
    }
    
  10. Logging In - This is the first part of the Lab, but since you can't see it in the lab until after you log in, the information is here:

    Once you are in your lab, one student from your pair should log into the lab computer.

    To log in, you use your zID (which looks something like z1234567) and your zPass (which is used to log into all other university online services).

    The CSE labs use the Linux operating system (not Windows or OSX or ...).

    When you log in, by default, you'll be using the xfce4 window manager, and you'll see a linux desktop.

    If you are asked to select a panel click on use default settings.

    Along with menus that you can see, such as the Applications Menu in the top left corner, it also has a simple menu you can access by right-clicking anywhere on the desktop.

    Have a look around and see if you can work out how to open a web browser.