Added solution for printing function