Variable Scope Exercise 2

What's wrong with the following code fragment?

#include <stdio.h>

int my_global;

int function1()
{
   my_global = 6;
   my_local = 2;
   return 1;
}

void function2()
{
   int my_local = 10;
   my_global = my_local;
}

This program will not even compile. It will crash because of the reference to 'my_local.' Function2 is fine, because all the variables it references have been declared.

This code isn't a great example of programming with global variables - I'm open to suggestions about how to improve it...