done version of assign1.c