Arduino sensing incorrect voltage value

I am using my arduino to measure voltage but the value on serial monitor is inconsistent (usually oscillating between two values). So I checked the voltage on back of the board using multimeter(through the solder points) and was getting the correct voltage value. The problem seems to be with the Amega328p microcontroller(ADC). I have tried to take out the Atmega IC but it doesn’t come out.Is buying a new board my only option?

the code I am using is the example code readvoltage.

Thanks

(usually oscillating between two values

which two values?

Well when I tried to measure 2.50 V , I got 2.77 and 2.72 (using usb as power supply). Using battery, 2.68, 2.69 and more. Do I need to use filter while giving supply to arduino?

This example https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage? It is using VCC as reference voltage. It is default. VCC is not stable in time and not accurate 5V. More stable is internal band-gap reference voltage but its value is not precise 1.1V, can differ cca 10%. It depends on several factors. The best result can be obtained if you detect exact value of band-gap first. The divisor should be 1024, not 1023. If you want to obtain more stable readings, you would connect capacitor (e.g. 100nF) between ATmega's input and GND for noise filtering.