In the exam you are given a Periodic Table. Use it to find the symbol of each element from its name. It also helps you work out formulae, because elements in the same group have the same number of electrons in their outer shell and behave in a similar way.
For ionic compounds, the group number gives the charge of the ion. Group 1 metals form ions with a charge of 1+, Group 2 metals form 2+, Group 6 non-metals form 2- and Group 7 non-metals form 1-. The compound is neutral, with no overall charge, so the charges must balance. Calcium is in Group 2 and chlorine is in Group 7, so one calcium ion needs two chloride ions, giving CaCl2. Potassium is in Group 1 and oxygen is in Group 6, so two potassium ions are needed for each oxide ion, giving K2O.
For simple covalent compounds, the group number shows how many bonds an atom forms. Hydrogen and Group 7 atoms form one bond, Group 6 atoms form two, Group 5 atoms form three and Group 4 atoms form four. Oxygen is in Group 6, so it forms two bonds, and hydrogen forms one. Water therefore has two hydrogen atoms for each oxygen atom: H2O. Once you have the formulae, balance the equation by changing the big numbers in front, for example 4K + O2 → 2K2O.