The answer to this question is actually a bit complicated, thanks to some disagreements among botanists about the term “vegetable” and the efforts of the grocery industry, which have further clouded the difference between fruits and vegetables. Simply put, a fruit is the ovary of a plant, which means that it may contain seeds, while a vegetable is a plant part, which does not contain seeds, although some vegetables may be used in plant reproduction.
Some examples of fruits include well-known specimens like apricots, cherries, blueberries, and apples, but tomatoes, pumpkins, cucumbers, and zucchini are also considered to be fruits botanically, even though many people refer to these fruits as “vegetables” because they are savory, rather than sweet. This is the result of convenience labeling used in the grocery industry, where fruits and vegetables are differentiated on the basis of whether they are sweet or savory, rather than with the use of any firm botanical criteria.
A vegetable, on the other hand, is simply a plant part like a flower, stem, root, or leaf. Broccoli, for example is a vegetable which appears in the form of a flower, while celery is a stalk vegetable, and celeriac is a root vegetable. Vegetables like potatoes are technically tubers, not roots, meaning that they are specially designed plant structures which store nutrients for the parent plant; tubers are also capable of budding into new plants. Some examples of leaf vegetables include spinach, cabbage, and lettuce.
The difference between fruits and vegetables should be fairly clear now; basically, if it has seeds, it's a fruit, and if it doesn't, it's a vegetable. However, there are some interesting little facts about fruit which may interest you; for example, all nuts are technically fruits, in addition to being classified as nuts, because they are plant ovaries. In the case of nuts, instead of eating the fleshy casing which surrounds the seed, we eat the seed. Grains are also fruits, because they are simply oversized seeds.
Some botanists also dislike the term “vegetable,” because they consider it rather vague and imprecise, and they would prefer it if crops were not arbitrarily broken up into the categories of fruits and vegetables. However, this nomenclature is likely here to stay, imperfect as it may be, so botanical sticklers may want to get used to hearing “fruits and vegetables” when produce is under discussion.