In gymnosperms and flowering plants, the megaspore is produced inside the nucellus of the ovule. During megasporogenesis, a diploid precursor cell, the megasporocyte or megaspore mother cell, undergoes meiosis to produce initially four haploid cells (the megaspores).