ENGGEN131 (2016) - CodeWrite

Learning a new programming language can be difficult. One of the first hurdles is getting familiar with the syntax - this must be tackled before you can start doing interesting things like problem solving.

In ENGGEN131 this semester we will be using CodeWrite, an online programming exercise tool, to gain practice solving small programming problems in C to help build your confidence with the language. CodeWrite also allows you to create exercises of your own, that other students in the class can use for practice.

Getting started

Your username for CodeWrite is your usual University username (e.g. abcd001).
Your password for CodeWrite is your ID NUMBER.

Log in to CodeWrite here:

PHASE ONE: answering exercises deadline: Mon 26th Sept, 11:59pm

When you first log in to CodeWrite, you will see a course named: "ENGGEN131 (C Module) 2016" as shown in the screenshot below:

There are several exercises in this area for you to solve. In this first phase of the activity, you cannot create your own exercises - you just need to solve the exercises that already exist.

Why won't my code compile?

It can be frustrating when your code does not compile. CodeWrite has been set up to be very strict. If your code generates any warnings, it will not compile. So the code you write must not only be syntactically correct, but it must also be well formed (such as not declaring variables you don't use, and making sure all control paths contain a return).

What do you mean "all control paths contain a return"?

The compiler is not as smart as you or I. If you write the body of a function with this general form:

if (...) {
   return ...
} else if (...) {
   return ...
} else if (...) {
   return ...
}

the compiler cannot verify that one of those three return statements will definitely be executed. As far as the compiler is concerned, each return statement has a corresponding condition, and only if that condition is true can the return statement be executed. The compiler cannot work out the truth values of those conditions. It will therefore generate an error telling you that not all control paths return a value (because, if all conditions were false, then no return would be executed!).

To fix this error, you will need to re-write the logic of your code. Either you will need to make sure there is an else clause (the compiler will then know that at least one of the branches must be executed):

if (...) {
   return ...
} else if (...) {
   return ...
} else {
   return ...
}

or you will need to include a return outside of the conditional statement:

if (...) {
   return ...
} else if (...) {
   return ...
} else if (...) {
   return ...
}
return ...

PHASE TWO: creating your own exercise deadline: Tue 4th Oct, 11:59pm

Starting on Tuesday morning (27th Sept), you will be able to create a programming exercise for your classmates to practice with. You are required to create just one exercise (although you may create more than this if you wish).

When you create an exercise, you must write a clear description of the problem that needs to be solved. Keep in mind, this description is the only thing that other students will see if they are attempting your question - so all of the information they need to solve the problem must be clear and unambiguously presented.

How to create an exercise on CodeWrite

STEP 1: Write a clear description of the function that needs to be written.

STEP 2: Define your model answer - that is, provide the correct code for your function

STEP 3: Provide a set of test cases. In the box on the left-hand side, you must provide a code fragment that calls your function and prints the output using printf(), and in the box on the right you must display the output that should be produced. You must provide at least 5 test cases, and you can also provide a hidden test case if you wish.

STEP 4: Check that the question is well written, and correct

STEP 5: Save the question to publish it, and check back to see how well others are answering it!

Assessment

The main goal of this activity is to give you practice writing short fragments of C code to build up your confidence and familiarity with the language. Please keep that in mind... however, there is also 2% credit to be earned.

To receive 2% credit for the CodeWrite activity you must complete ALL of the following:

How "good" does the question I make need to be?

To receive credit for this task, you need to create a "good" question. Here are some things to keep in mind:

Remember, you need to create 1 exercise at a minimum, although you are welcome to create more:

Can I just choose easy questions to answer?

That's up to you - to earn the 2% credit, you simply need to solve at least 5 additional exercises on top of the compulsory exercises for Phase One:

Having said that, you will probably feel better about yourself if you push yourself a little!

My CodeWrite user interface looks different to my friend!

Everyone has been randomly assigned a particular "themed" interface (which determines things like badges and leaderboards) - it makes absolutely no difference to the content (exercises, solutions, etc.) as everyone sees all of the content regardless of the interface theme. Just roll with it.

Help! I can't log in to CodeWrite!

Are you sure you are using your ID number as your password, and you are trying to log in here:

Questions?

If you have feedback or corrections, please contact Paul Denny (paul@cs.auckland.ac.nz).

19th September, 2016