Melons and Pumpkins
Melons are a useful food source, and are used in brewing potions. Pumpkins are not edible, but can be worn as a helmet for protection against Endermen. Pumpkins are also used for crafting Jack'o'Lanterns, a decorative lighting fixture.
Building a Farm
Melons and pumpkins grow on hydrated farmland (for a quick guide to farmland and irrigation, see here).
The plant grows on one square of farmland, and when it is mature, melons or pumpkins will start to appear on an adjacent farmland square.
Here are two layouts for a small and a large farm.
Light and Fences
You will need to provide plenty of light if farming underground. Fences or something to keep mobs off your farmland may also be a good idea.
Plant the seeds on the farmland. They will start to grow.
You can make the plants grow instantly using bonemeal, but it will still take time for the fruits to appear.
Harvest the fruit (an axe makes quick work of pumpkins, and a sword is good for melons, but anything will do), and you will see that the plant remains, but the farmland that the fruit grew on has reverted to dirt.
Use your hoe to make it back into farmland, and another melon or pumpkin will grow. Another melon or pumpkin will grow soon!