Car sometimes crank but doesn't start, and sometimes just makes a click sound. on 1999 Mercedes-Benz C230

Problem occurs random. Sometimes when I turn the key it does not crank but just makes a clicking sound. Most times it will crank but shuts down immediately after the engine turns over. Already changed crank position sensor, but the problem is still there.

Asked by for the 1999 Mercedes-Benz C230
check battery