I have a pressure sensor working at 24V dc whose output is analog 0-10V for 0-10bar pressure. I am using this sensor with Arduino Uno. I know that the pressure value will never go beyond 4bar. So do I have to use a voltage divider in this case or not using it will still do the job?
If we assume your Arduino Uno is powered from 5v, then what you appear to be asking is 'if my sensor voltage always stays within the range 0 to 4v, will it be OK to put it into and ADC that can accept 0 to 5v input?'
Under normal conditions, the answer is obviously yes.
The experienced designer designs things so that they work under 'normal' conditions, and don't break under possible but 'abnormal' conditions. Will your sensor output ever go above 5v? What about a brief blip when it's first switched on? What about water hammer in the pipes you're measuring?
It would be prudent to check how much current the Uno input can accept without damage when the voltage exceeds the rail, and use at least a series resistor between sensor and Uno to limit the current to less than this under fault conditions.
You might not need a voltage divider considering the range in normal operation, but I recommend a series current limiting resistor to protect the sensor, a clamp diode to Vcc, possibly another series resistor after the clamp diode to protect the ADC, and possibly a smoothing capacitor on the ADC input pin.