One thing I can think of is having a delay of 100ms in the code and multiplying the instantaneous speed by 100mS. Since all other function execution should take a maximum of 1-5mS (including ADC conversion and sending bits to LCD displays etc), I can neglect that time and consider the distance here. But this method is not very exact. Does anyone have a better solution?

PFA the basic code

currentSpeedVoltage = ADC_Read(9);

currentSpeedVoltage = (currentSpeedVoltage * 0.001220703125); //(0.001220703125 = 5/4096) (12 bit resolution for ADC)

currentSpeed = (currentSpeedVoltage*25)/18; // assumed here that at 18 Volts, we show the speed as 25 Km/hr.

distance += (currentSpeedx100x5*(pow(10,-5))/18)/1000;