I should have mentioned this, but without the capacitor it shows some error when uploading the program, that's why i am not able to use it
Do you mean you are powering it via "Vin" or the "barrel jack"? That should have no effect when only the USB is connected to program it.
Really, you should not consider powering it via "Vin" or the "barrel jack" as a viable means. The electronics operates on 5 V, so you should be powering it fom 5 V.
My routine advisory:
The clear blunder is not comprehending what the "Vin" or "RAW" terminal is. The regulator on the Arduino UNO/ Nano/ Pro Mini/ Mega2560/ Leonardo/ Pro Micro has very little heatsink, so will not pass very much current (depending on the input voltage and thus, how much voltage it has to drop) before it overheats and (hopefully reversibly) shuts down. It is essentially a novelty provided in the very beginning of the Arduino project when "9V" power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.
Nowadays, 5 V regulated switchmode packs are arguably the most readily available in the form of "Phone chargers" and switchmode "buck" regulators to regulate down from 12 V or other available voltages are cheap on eBay so these can be fed into the USB connector or (more appropriately) 5 V pin to provide adequate power for most applications. Unfortunately, many tutorials or "instructables" are seriously outdated or misleading and have not been updated to reflect the contemporary situation.
If powering from batteries, as long as the battery pack cannot exceed 5.5 V, this must be connected to the 5 V pin.