Flowering plants alone produce fruits. Fruits are the result of process of pollination in which pollen is transferred from the male part of a flower to female part of same or a different flower. Fertilization happens and fruits evolve. Fruits come in lots of sizes and shapes.
Flowers start to become fruit when the pollen fertilizes the egg inside an ovule. While the ovule develops into seeds, the part which holds the ovule called the ovary goes through lots of changes. The ovary acts as a protective layer surrounding the seeds. Depending on the kind of fruit, it develops either inside or on the outside.
Simple fruits are those that form from one ovary from a single flower. Simple fruits include oranges, apples, cherries and nuts. Aggregate fruits are those that form from multiple ovaries within a single flower. Strawberries are an example of aggregate fruits. Multiple fruits are those that form when many ovaries each from different flowers all merge together to form one fruit. Pine apples are examples of multiple fruits.
In some cases the ovule develops into three distinct layers – an outer exocarp, a middle mesocarp and an inner layer called the endocarp. In a peach for instance, the thin outer skin is the exocarp, the juicy flesh is the mesocarp and the stony pit that encloses the seed is the endocarp. Fruits that develop this way with very obvious layers like those in cherries, peaches, plums, coconuts are called drupes.
Apples, pears, quinces and all other core fruits are called pomes. They develop in a different way. The pericarp (fruit wall) forms only the seed-containing core at the centre of the fruit. The edible flesh is formed by the enlargement of the floral tube that actually surrounded the ovary.
Fruit has to come from a flower but at the same time not all flowers become fruits. Changes in weather conditions, availability of pollinators can affect the pollination process.