So let's say  there was question like:
A 200 mL solution contains 3.98 g of glucose (C6 H12 O6). What is the molarity of this solution?
The first step is to find the molar mass/ molecular weight. 
Carbon:  6 x 12.0107=72.0642
Hydrogen :12* 1.00794=12.09528
Oxygen 6*15.994= 95.664
Now add them all up, you should get: 
179.82 grams/mole.
 What you have to do know is look at equation again, it says A 200 mL solution contains 3.98 g of glucose, which means the solute  is glucose. how much glucose? 3.98 grams of glucose!
so 3.98 is divided by molar mass. 
The answer is: 0.022 moles (C6 H12 O6).
You need to know the conversion factor.
 1 L/ 1000 mL
You would have to divide  200 mL with 1000 mL.
 it would  be  0.2 liters. 
now  just divide  0.022 moles/ 0.2 liters = 0.11 M (molarity) 
You would do the same thing molality except it is looking at the solvent and converting grams to kilograms.