First-principles study of bulk and (001) surface of TiC