coded in C, one of the class project for VT