A programmer can certainly include a disclaimer of liability in the terms of service, terms of use, or license document. May apps and software packages include such disclaimers. The words "sold as is" will probably be part of such a disclaimer.
However, some US states impose warrentees of "merchanability" and "fitness" for the designed purpose, even if there is a disclaimer. This is more likely if the software is considered a "consumer product". If it is marketed for business use some jurisdictions will not impose such liabilities.
The programmer can also include in a disclaimer a provision that any liability under such an imposed warrentee is limited to the purchase price of the software. This may or may not be fully effective.
Still you may want to require users to accept your terms including a disclaimer with a button click or checkbox before allowing use of the software.
It is probably a good idea to consult a lawyer in drafting a disclaimer that will have he best effect in your particular jurisdiction. But remember that, if sold over the net, there may be purchasers in other jurisdictions.
Formation of a corporation, possibly in the form of an LLC, can limit liability and need not be as much work or expense as one might fear. But it has multiple implications, which are beyond the scope of this answer.
Of course, taking all reasonable precautions to avoid bugs is a good idea, but no programmer can be sure of writing totally bug-free code.