Q:

Easy C enum question

I have just started C very recently and I have been asked to answer some coding exercises in which the following piece of code appears:
typedef enum {
  false = 0,
  true = 1
} Bool;

Could someone please provide a brief and clear explanation to that?
Thanks very much.

A:

It's really doing two things; you can break it down something like this:
enum _bool {
   false = 0,
   true = 1
};

And:  
typedef enum _bool Bool;

This code creates a new enumeration type and then uses typedef to give it a convenient name.  It would let you use a new 'type' called Bool elsewhere in your code, and assign it the values false and true.  Here's a simple use case:
Bool logical_not(Bool in)
{
    if (in == true)
        return false;
    else
        return true;
}

A:

It's just a definition of an enum, a type that can assume only a discrete number of values, i.e. the ones enclosed in these brackets. Each of these values is given a name, that you can later use to refer to it. If you only specify the name of the values and not the actual value, the compiler will set them for you in increasing order, starting from zero for the first element.
See the wiki article about enumerated types (and in particular its C section) for more information.
That specific enum defines a boolean type, i.e. a type that can assume only two values: true and false, where false=!true. The boolean values are used very often in programming, for example as flags to indicate if a condition is met, and actually many languages include them as a native type (C++ and C99, for example, do that).
By the way, to define that enum this:
enum Bool
{
    false = 0,
    true = 1
};

would be enough; however, because of how C was designed to declare a variable of the Bool type with this code you would need to put always the enum keyword before Bool:
enum Bool myFlag=true;

Using the typedef trick, instead, you define an anonymous enum made in that way, and then you provide an alias to it named Bool; in that way you can simply do:
Bool myFlag=true;

