Sex determination is a process of development by which the sex of an individual is settled. Sex is a method of reproduction which is widespread among living things. It requires two individuals of the same species.

Usually, the sexes are separate. Sex may be determined in one of two ways:
 Genetically, by genes and chromosomes the organism inherits from its parents.
 Environmentally, by some outside agent acting as a trigger to development.

Where both sexes occur on the same individual, that individual is an hermaphrodite. Hermaphrodite systems can be found in some animals, for example snails, and in most flowering plants.

Determination by the environment 

For many species, sex is determined by environmental factors experienced during development. Many reptiles have temperature-dependent sex determination. The temperature embryos experience during their development determines the sex of the organism. In some turtles, for example, males are produced at lower incubation temperatures than females; this difference in critical temperatures can be as little as 1-2 °C.

Many fish change sex over the course of their life. This phenomenon is called sequential hermaphroditism. In clownfish, smaller fish are male, and the dominant and largest fish in a group becomes female. In many wrasse the opposite is true–most fish are female at birth and become male when they reach a certain size. Sequential hermaphrodites may produce both types of gametes over the course of their lifetime, but at any given point they are either female or male.

In some ferns the default sex is hermaphrodite, but ferns which grow in soil that has previously supported hermaphrodites are influenced by hormones remaining to develop as male.

Genetic determination 

The most usual way to determine sex is by genes. That way, an organism's sex is determined by the genome it gets. 
The alleles that influence sexual development may or may not be on the same chromosome. If they are, that chromosome is called a sex chromosome, and the genes on it are called 'sex linked'. Sex is determined either by the fact that there is a sex chromosome (which can be missing), or by the number of them. Because genetic sex determination is determined by matching chromosomes, there are usually the same number of male and female offspring.

Various genetic systems 
Humans and other mammals have an XY sex determination system: the Y chromosome carries factors responsible for male development. The default sex, in the absence of a Y chromosome, is female. XX mammals are female and XY are male. XY sex determination is also found in other organisms, including the common fruit fly and some plants. In some cases, including in the fruit fly, it is the number of X chromosomes that determines sex rather than the presence of a Y chromosome.

Birds have a system that works the other way round: It is called ZW sex-determination system. The W chromosome has factors for female development. By default (if the chromosome is missing), the organism will be male. In this case, ZZ individuals are male and ZW are female. The majority of butterflies and moths also have a ZW sex-determination system. In both XY and ZW sex determination systems the sex chromosome carrying the critical factors is often significantly smaller, carrying little more than the genes necessary for triggering the development of a given sex.

Many insects use a sex-determination system based on the number of sex chromosomes. This is called XX/XO sex determination–the O indicates the absence of the sex chromosome. All other chromosomes in these organisms are diploid, but organisms may inherit one or two X chromosomes. Infield crickets, for example, insects with a single X chromosome develop as male, while those with two develop as female. In the nematode C. elegans most worms are self-fertilizing XX hermaphrodites, but occasionally abnormalities in chromosome inheritance regularly give rise to individuals with only one X chromosome–these XO individuals are fertile males (and half their offspring are male).

Other insects, including honey bees and ants, use a haploid-diploid sex-determination system. In this case diploid individuals are generally female, and haploid individuals (which develop from unfertilized eggs) are male. This sex-determination system results in a highly biased sex ratio, as the sex of offspring is determined by fertilization rather than the assortment of chromosomes during meiosis.

Abnormalities 
Sometimes an organism develops the appearance of both males and females. It is then an intersex and is rare. Even though such organisms may be called hermaphrodites, this is not correct, because in intersex individuals either the male or the female aspect is sterile.

References 

Classical genetics
Developmental biology
Cell biology
Biological reproduction