Photosynthesis is the synthesis of glucose using energy from light, carried out by green plants and other photosynthetic organisms including some bacteria, algae, and protists such as euglena. A by-product of photosynthesis is oxygen, and photosynthesis is considered to be the source of the oxygen in our atmosphere. This oxygen is used by aerobic organisms, including animals, plants, and fungi, to make use of the energy in glucose via the process of cellular respiration, which is nominally the reverse of photosynthesis.
Photosynthesis is a complex, multi-step process involving dozens of proteins in light and dark reactions. When discussing the equation, however, we are referring to the net effect, going from starting materials through all the steps to finished product. The starting materials for photosynthesis are the compounds carbon dioxide (CO2) and water (H2O). Vascular plants (most familiar plants) obtain water from soil through their roots, and take in carbon dioxide from the air through openings in the undersides of their leaves, called stomata.
So far we have reactants carbon dioxide and water, combining with energy input from light to produce glucose and oxygen (O2). It is a fundamental tenet of chemistry that mass is conserved in a chemical reaction and, further, that the number of each kind of atom in the products of the reaction is the same as in the reactants. If we are able to specify the number of carbon atoms in the products, that must be the same number that we started with. Fortunately we know that the formula of glucose is C6H12O6, meaning it contains six carbon atoms, twelve hydrogen atoms, and six oxygen atoms. The formula of oxygen, as noted above, is O2, meaning it contains only oxygen, so the only carbon in the products is that in the glucose. Since the glucose contains six carbon atoms, there must also be six carbon atoms in the starting materials, carbon dioxide and water. A carbon dioxide molecule contains only one carbon atom, so the plant must take in six of them in order to make one molecule of glucose.
We can write a balanced equation, showing the correct numbers of each substance in the reaction so that the numbers of atoms of all elements are the same on both sides of the reaction:
6 CO2 + 6 H2O (+ energy) —> C6H12O6 + 6 O2
Note that the equation for aerobic cellular respiration is the exact reverse of this and also that plants not only perform photosynthesis, they also utilize cellular respiration to get the energy they have stored in glucose into the form used in cellular processes, the energy molecule ATP.