function codes for lab7_3.c