COMP1911 23T2 Introduction to Programming
  1. What is your tutor's name, e-mail, how long have they been at UNSW, what are they studying, what is 1 interesting thing about them?
    Answered in tute.
  2. What are your class mates's names, what are they each studying, what is 1 interesting thing about each of them?
    Answered in tute.
  3. Are there any marks for attending lectures, tutorials or labs?
    No attendence marks for lectures, tutorials or labs.

    There are marks for completing lab exercises.

    BUT it is highly recommended to attend your lectures, tutorials and labs to get the most out of the course

  4. Where is the CSE Help desk and what do they help with?
    The CSE Help desk is in K17, Level 1, Room 111.

    They can help you with anything related to using CSE's computers.

    For help with accounts, passwords & printing, etc. contact UNSW central IT

    Your tutor and/or assistant tutor may only be able to provide limited help during your lab times.

  5. How do I find COMP1911 on Moodle?
    COMP1911 only uses Moodle for Online tut-labs and Help Sessions.

    And for access to Lecture Recordings.

    A link is avalible on WebCMS.

  6. What is an operating system?
    What operating systems are running in your tute room?
    What operating system do CSE lab computers run?
    An operating system is a piece of software that abstracts and manages the hardware of a computer and provides an interface to the programs that run on the computer.

    Operating systems on phones in your tut room might include Android, IOS (Apple), Windows.

    CSE's lab computers and servers run Linux (Debian 5.10 (`$ uname -a`)).

  7. On windows, is the control panel and file explorer part of the list of applications, or part of the operating system?

    They are part of the operating system's list of applications. The operating system is a more low-level, non graphical part of the computer. Nearly everything you see and understand in a computer is just the application layer built on top of an operating system. And this operating system allows all applications to abstract away the underlying hardware and devices that your software is running on.

  8. What is a file in the context of computers? What kind of files are used in COMP1911?
    A file is a piece of information, or more precisely a sequence of bytes (in the form of binary bits) which is stored semi-permanently.

    Files for CSE users are kept on disks connected to servers in K17.

    COMP1911 students will need to store C programs in files. They might also need to store, for example, input data for these C programs, machine code produced by compiling these C programs. These will all be separate files of different types.

  9. What is a file extension? Do they matter?
    A file extension is usually a suffix to a file name (after a ".") that tells an operating system what "type" of file it is. An operating uses this to know what application to open the file in.

    Changing the file extension does not change the file itself or it's contents. You can manually change a file extension or remove it altogether and still manually open it in your program of choice.

  10. If I have written a fantastic C program in a file named stuff.c how could I execute it to show it off to my friends?
    The computer does not understand C code. Code is for humans. You would need to compile it first using dcc or gcc to create machine code that the computer can execute. Possible commands to do this would be
    dcc stuff.c -o stuff
    ./stuff
    
    Or if you were not on a cse machine or cse's vlab you could use gcc with these flags
    gcc -Wall -Werror -O stuff.c -o stuff
    ./stuff
    
  11. What is the difference between gcc and dcc?
    dcc and gcc both translate C programs to machine code which can then be executed but dcc can detect more errors and gives more helpful error messages than gcc. We will be using dcc in the course, but you may need to use gcc on other systems that don't have dcc.

    With gcc it is advised to run with the flags -Wall -Werror and -O to give more help with compile errors. dcc already does that for us anyway but is even more helpful. Note: when we test and mark your programs at uni we use dcc, so always make sure any code you submit compiles using dcc and runs on the cse machines/server.

  12. What is a text file? Give examples of text and non-text files.
    A text file is file containing representations of alphabetic characters of a particular language. It is designed to contain information that can be read when opened by a program. An example is the source to a C program.

    The machine code file produced by gcc or dcc (a.out by default) is an example of an non-text file.

  13. What is an editor used for in COMP1911? How many editors are installed on CSE lab machines? Which one is recommended for COMP1911 students?
    In COMP1911 you need to use an editor to create and modify the text of your C programs.

    Over 20 editors are installed on CSE systems. A simple one named gedit is recommended for COMP1911 students.

    However, gedit only works on systems with a GUI. If you are interacting with command line only then common ones used are vim and nano

  14. What is machine code? Why does a COMP1911 student need machine code, how to they create it and where to they keep it?
    Machine code is the binary instructions that can be directly by the CPU (central processing unit) of a computer.

    COMP1911 students need machine code so that can execute the programs they write.

    COMP1911 students obtain machine code by creating a C program then using dcc or gcc to translate it to machine code.

    They keep the machine code in files. If you don't specify a file dcc and gcc put the machine code in a file named a.out.

  15. What are some basic Linux commands do you need to know to do the complete the first COMP1911 labs, and what do they do?
    The important ones are:
    gedit
    A simple text editor suitable for 1911 students to use to create files containing C programs.
    dcc
    Translates C programs to machine code which can then be executed.
    ls
    By default lists the files in the current directory. You can also specify a directory to list.
    cp
    Copy a file.
    rm
    Remove a file
    mkdir
    Create a directory.
    For example mkdir lab02 creates a directory named lab02 in the current directory.
    cd
    Change your current directory.
  16. Discuss the following features of the sample program from lectures:

    // Author: Hayden Smith (hsmith@unsw.edu.au)
    // Date created: February 2019
    // My first C program
    
    #include <stdio.h>
    
    int main (void) {
        printf ("COMP1911 is my favourite computing course!\n");
    
        return 0;
    }
    
    • the \n
      It outputs a newline at the end of the line, following the character sequence Hello World!, 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?

      An example of a comment 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 read the code!

      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.

  17. Is the style-guide a good recommendation for how to write clean code?
    Yes. However, in COMP1911 it is not just a recommendation, but also a requirement. Please right all of your code with strict adherence to the style guide.
  18. 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;
    }