A. The cost of producing widget number 31 should be the cost of producing 31 widgets minus the cost of producing 30 widgets which is:
C(31) - C(30) = (5000 + 40*31 - 0.02*312) - (5000 + 40*30 - 0.02*302) = 6220.78 - 6182 = 38.78
B. Marginal Cost is defined as C'(x) since the cost equation is C(x).
C'(x) = 40 - 0.04x
C'(30) = 40 - 0.04*30 = 40 - 1.20 = 38.80