Percentage composition is the percentage by mass of each element in a compound.
"% by mass" = "mass of element"/"total mass of all elements" × 100%
To find the % composition of "CO", you calculate the % by mass of each element in a given mass of "CO". It is simplest to use 1 mol of "CO".
1 mol "CO" contains 1 mol of "C" and 1 mol of "O".
28.01 g "CO" contain 12.01 g "C" and 16.00 g "O".
"% C by mass" = "mass of C"/"mass of CO" × 100 % = (12.01 color(red)(cancel(color(black)("g"))))/(28.01 color(red)(cancel(color(black)("g")))) × 100 % = 42.88 %
"% O by mass" = "mass of O"/"mass of CO" × 100 % = (16.00 color(red)(cancel(color(black)("g"))))/(28.01 color(red)(cancel(color(black)("g")))) × 100 % = 57.12 %