Scientists use molarity to designate the amount of a chemical (solute) in a volume of solution. Typically, the units in which molarity is reported are moles per liter, and a capitalized "M" is used as a symbol for the words "moles per liter." A one molar solution of sodium chloride (salt, or NaCl) is frequently referred to as a 1.0 molar or 1.0 M NaCl solution. Calculation of the molarity of a solution thus involves determining how many moles of the solute (e.g., NaCl) are present in a liter of the solution.
One mole is Avagadro's number: 6.022 * 10^23 units of anything. In the case of molarity of a solution, 1 mole refers to 6.022 * 10^23 molecules of a compound such as NaCl.
It is a simple matter to calculate the number of moles of a compound from its weight. This is done by weighing the compound and dividing the weight by the gram molecular weight (GMW) of the compound. You need to look up the atomic weights of each element in the compound. You can find the atomic weights of elements on periodic charts of the elements and in textbooks and chemistry handbooks. For NaCl, you would add the atomic weight of sodium to that of chlorine to get the GMW of NaCl. Since the atomic weight of sodium is 22.99 g per mole and that of chlorine is 35.45 g per mole, the GMW of NaCl is 58.44 g per mole.
For a compound such as sodium sulfate (Na2SO4, you need to double the atomic weight of sodium (Na) and quadruple the atomic weight of oxygen (O) and add them to the atomic weight of sulfur (S), since there are two sodium atoms and four oxygen atoms in each sodium sulfate molecule.
You can calculate the number of moles of your compound by dividing the number of grams of the compound by the GMW of the compound. If you have 100 g of NaCl, you would calculate the number of moles by dividing the 100 g by the calculated GMW of 58.44 g per mole to get 1.71 moles of NaCl.
Now that you know how many moles of solute you have, you can add the compound to your solvent to make a solution. Next, measure the volume of the solution. Now divide the number of moles of the solute by the volume of the resultant solution (in liters) to find the molarity.
In the above example, if you dissolved the 100 g (1.71 moles) of NaCl in enough water to make 1 liter of solution, you would have a 1.71 M NaCl solution. If you dissolved the 1.71 moles of NaCl in enough water to make a 1.71 liter solution, you would have a 1.0 M solution.