This is perfunctorily answered by a quick trip to Wikipedia:
In botany, a fruit is a part of a flowering plant that derives from specific tissues of the flower, mainly one or more ovaries.
...
In common language usage, fruit normally means the fleshy seed-associated structures of a plant that are sweet and edible in the raw state, such as apples, oranges, grapes, strawberries, and bananas. On the other hand, the botanical sense includes many structures that are not commonly called "fruits", such as bean pods, corn kernels, wheat grains, tomatoes.
This distinction is supported by other dictionaries and glossaries, such as University of North Carolina's Plant Information Center:
Matured ovary of flowering plants, with or without accessory parts
Or the Dictionary of Botany:
- The structure that develops from the ovary wall (*pericarp ) as the enclosed seed or seeds mature. A fruit may be classified as succulent or dry depending on whether or not the middle layer of the pericarp (the *mesocarp ) develops into a fleshy covering. It may be further classified as dehiscent or indehiscent according to whether or not the fruit wall splits open to release the seed. Fruits that develop from the gynoecium of a single flower are termed simple or true fruits (see illustration for the main types of true fruits). If they are derived from a single ovary they are termed monocarpellary while those that incorporate a number of fused ovaries are termed polycarpellary. An *aggregate fruit may develop from an apocarpous gynoecium. The fruit may incorporate tissues other than the gynoecium (see pseudocarp) and some fruits may develop from a complete inflorescence (see multiple fruit ). In some cases a fruit may develop even though the ovule has not been fertilized (see parthenocarpy).
- Loosely, any of various fleshy structures that may be associated with a gymnosperm seed, such as the succulent *aril of yew (Taxus baccata) or the fleshy ovuliferous scales of some members of the Podocarpaceae, such as junipers (Juniperus

Compare this to vegetable:
Wikipedia's Vegetable page explains:
As an adjective, the word vegetable is used in scientific and technical contexts with a different and much broader meaning, namely of "related to plants" in general, edible or not — as in vegetable matter, vegetable kingdom, vegetable origin, etc.
...
The noun vegetable means an edible plant or part of a plant, but usually excludes seeds and most sweet fruit. This typically means the leaf, stem, or root of a plant but also includes some fruits as well (such as squash).
In a non-biological sense, the meaning of this word is largely based on culinary and cultural tradition. Therefore, the application of the word is somewhat arbitrary and subjective. For example, some people consider mushrooms to be vegetables even though they are not biologically plants, while others consider them a separate food category.
So, in science, a fruit is a specific part of a plant, and vegetable is an adjective referring to plants.
At the greengrocer, fruit is more loosely defined, and vegetable covers edible parts of the plant that aren't fruits or seeds (including grains).