An analogue of the ostrowski inequality and applications