We are all somewhat sloppy when we use the term percentage. We should always ask the question "percentage of what?"
When you say that you marked up your cost 45% to get $34.51 you did exactly what I would have done. Your cost was $23.80 and 45% of $23.80 is 0.45 $23.80 = $10.71. This is your gross profit.
You want your gross profit as a percentage and I want to know, a percentage of what? If you want to express your gross profit as a percentage of your purchase price then it is 45%. That's what you did. If you want your gross profit as a percentage of your selling price then you need to ask:
What percentage of $34.51 is $10.71?
I translate this English statement into a mathematical statement (equation) using the following
- "what" is the unknown, call it x
- "percent" is per-one-hundred, that is over 100
- "of" is multiplication
- "is" is the verb, which in an equation is the equal sign
Thus the English statement above becomes
x/100 $34.51 = $10.71
Solving for x yields
x = 31.03
Hence the gross profit is 31% of your selling price.