There are some errors in the math on the previous comment. To put it into easy to understand terms:

For each component, you divide the partial pressure for that component by the gas constant. Then divide the result by the temperature. This will give you the concentration of that component in moles per liter. If you need to know how many moles you have then you multiply by the total air volume.

Make sure you are using the right units before you do any math!!! P should be in atm. V should be in Liters. T should be in Kelvin (absolute temperature). Thus R should be L*atm/(mol*K) to make the math work.

Remember, partial pressure is equal to the fraction of that component in the gas (in terms of either volume percentage) multiplied by the total gas pressure. If you are working at 1 atm pressure, then the partial pressure is the same number as the percent of the air that is that gas, hence N2 is 0.78 atm and O2 is 0.21 atm, and CO2 is 0.01 atm (roughly) for regular dry air at sea level. And if you want to be VERY specific, like for some gas other than air, you will want to use a slightly modified version of this equation to fit the specific gas you are working with. Since not all gases are "ideal" and this equation is the "ideal gas" equation.

C(mol/L) = f(L of your gas / L of all gases) * P(atm) / [R(L*atm/(mol*K)) * T(K)]

n(mol) = C(mol/L) * V(L of total gas)

N2: C = 0.7808*1atm / (0.0820575 * 273.15 L*atm/mol) = 0.0348 mol/L

O2: C = 0.2095*1atm / (0.0820575 * 273.15 L*atm/mol) = 0.00935 mol/L

average air: C = 1atm / (0.0820575 * 273.15 L*atm/mol) = 0.0446 mol/L

real dry air: C = C(N2) + C(O2) + C(Ar) + C(CO2) + C(H2O)

= 0.0348 + 0.00935 + 0.000415 + 0.00001740 + 0

= 0.0446 mol/L

Note that the real calculation for air, using each individual component, and the quick-and-easy average air calculation using P = 1atm, they are ALMOST identical. Depending how accurate your calculation needs to be, they differ by about 5*10^-7. Also remember this is for DRY air, with ZERO water content. If your air has any water, it will slightly affect the result. Also remember this is very highly dependent on TOTAL air pressure and on temperature, so make sure you are using the proper P and T values.