Profit and Loss
Given separate cost and selling prices as nonnegative integer amounts in paise, return selling price minus cost price in paise. One rupee is 100 paise.…
Given separate cost and selling prices as nonnegative integer amounts in paise, return selling price minus cost price in paise. One rupee is 100 paise. Positive means profit, negative means loss, and zero means break-even. Preserve the sign; the prices describe one fixed transaction.
Each price is an exact integer from 0 through 2147483647 paise. Return an exact signed integer in [-2147483647, 2147483647]. No decimal-input parsing, rounding, currency conversion, percentages, tax or fees.
Example 1: input cost_paise = 12500, selling_paise = 15250; output 2750. Selling price exceeds cost by 2750 paise.
Example 2: input cost_paise = 15250, selling_paise = 12500; output -2750. Selling below cost produces a negative loss of 2750 paise.
Example 3: input cost_paise = 100, selling_paise = 125; output 25. The exact 25-paise profit is smaller than one rupee.
Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.