Using the molar mass of Carbon, 12g/mol, we know that in 12 grams of it we have 1 mol, therefore:
12g = 1 mol
6.0g = x moles
x = 0.5 moles of Carbon in 6 grams