COMP 1917
Computing 1
Session 2, 2016

Tutorial - Week 2

Tutorials are normally released on Thursday of the week before they are due. In Week 2, your tutor will bring printouts of this page. In future weeks you will need to bring your own printout.

Tutorial Presentations

From Week 3 onwards, each tutorial will begin with a presentation by a pair of students. The presentation will run for 10 minutes, from 5 past the hour to 15 past the hour.

During each tutorial, your tutor will choose a pair of students to present the following week. If you know you will be away at some time during the session, try to ensure you are not allocated to that week. You should be prepared for the possibility that you might have to give the presentation on your own (if your partner forgets or is unable to show up due to illness, etc.)

The topic for each week's presentation will appear at the end of the previous week's tutorial questions.


Week 2 Tutorial Questions

  1. Introduce yourselves, get to know your tutor - how can you contact them?

  2. Get to know your classmates - what are they studying?

  3. State briefly what each of the following Unix commands does:

  4. Which of the following are valid variable names in C? Which are not?

  5. Write a C program which allows the user to enter a number and then prints the square root of that number, to two decimal places:
     % Enter a number: 42
     The square root of 42.00 is 6.48
     %
    
    How should your program behave when a negative number is entered?

  6. How would you modify your program so it computes the cube root instead of the square root? (Hint: use the pow() function, described here).

  7. Suppose you have written a C program and saved it to a file heron.c. What would you type on the UNIX command line to compile this program, producing the object file heron ? How would you then run this program?

  8. Write a program which inputs the sidelengths a, b and c of a triangle, and computes the area of the triangle using Heron's formula:
       area = sqrt(s(s-a)(s-b)(s-c))
    
    where s is the "semi-perimeter"
       s = (a + b + c)/2.
    
    (Note: You will be implementing and modifying this program during the Lab).

  9. Have you made any progress in setting yourself up for HomeComputing? Now would be a good time to discuss any problems/advice/suggestions with your classmates.

Presentation Topic for Week 3

Given a point P=(x,y) and a triangle ABC with A=(x1,y1), B=(x2,y2) and C=(x3,y3), how can you test whether the point P is inside or outside the triangle? Find out one or two methods for doing this and explain them to the class. (Note: you should explain them using mathematical formulas, not actual C code.)