It also depends which cruise line you are holidaying with, which ship and the duration of your trip.
A 14 night cruise in the Caribbean (with Princess) will mean 3/4 formal nights. Other nights it is smart/casual ('normal' clothes you'd wear to a local restaurant). Most people do dress up for formal nights but you don't have to, although you may not be allowed into the main dining rooms if you are not in suitable attire. We only did one formal night. The other two nights we wore smart/casual and dined at the 24-hour buffet. In fact, it was sometimes difficult to distinguish between those who were formally dressed and those who were not.