solution of program assignment2