From the straight dope:
A fruit is the matured ovary of a flower, containing the seed. After fertilization takes place and the embryo (plantlet) has begun to develop, the surrounding ovule becomes the fruit. Yum. I won't go on about the four types of fruit--simple, aggregate, multiple and accessory--which explain things like berries and pineapples.
A vegetable is considered to be edible roots, tubers, stems, leaves, fruits, seeds, flower clusters, and other softer plant parts. In common usage, however, there is no exact distinction between a vegetable and a fruit. The usual example is the tomato, which is a fruit, but is eaten as a vegetable, as are cucumbers, peppers, melons, and squashes. The classification of plants as vegetables is largely determined by custom, culture, and usage.
Okay, now the part which may surprise you. A grain is described as the dry fruit of a cereal grass, such as the "seedlike fruits of the buckwheat and other plants, and the plants bearing such fruits." So, grain is also a fruit.
Which brings us to the nut. Yes, you guessed it, a nut is, in botany, "a dry, one-seeded, usually oily fruit." True nuts include the acorn, chestnut, and hazelnut. The term nut also refers to any seed or fruit with a hard, brittle covering around an edible kernel, like the peanut, which is really a legume. A legume is defined as "(the) name for any plant of the pulse family; more generally, any vegetable. Botanically, a legume--a pod that splits along two sides, with the seeds attached to one of the sutures--is the characteristic fruit of the pulse family." Say what? A "pulse" is "the common name for Leguminosae or Fabaceae, a large family of herbs, shrubs, and trees, also called the pea, or legume, family. " Please, make it stop!
So I guess we have learned today that just about everything is a fruit, unless of course, it's a vegetable or a legume.