u8的汇兑损益的计算公式
Here, we are going to calculate how much we gain the profit or loss on a product through cost price and selling price. When we purchase a Car in an "xxx" amount, it is called its cost price and then if we sell the Car in "yyy" amount, it is called its selling price, if "xxx" is greater than "yyy" then it will be a loss and if "yyy" is greater than "xxx", then it will be a profit.
在这里,我们将计算通过成本价格和售价获得的产品利润或损失。 当我们以“ xxx”金额购买汽车时,将其称为成本价,然后,如果我们以“ yyy”金额出售汽车,则将其称为售价,如果“ xxx”大于“ yyy”,则价格为将是亏损,并且如果“ yyy”大于“ xxx” ,则将是利润。
Example: I purchased a house in Rs. 3000000 after that I sold that house after 2 years in Rs. 4000000. The sold price is higher than its purchased price, thus it will be a profit of 1000000.
示例:我在卢比买了房子。 3000000之后,我以2卢比的价格卖掉了那所房子。 4000000。出售的价格高于其购买的价格,因此它将是100万的利润。
用C语言计算损益 (Calculate profit or loss in C language)
#include <stdio.h>
int main()
{
/*declare the variables*/
int cp;
int sp;
int amount;
/*enter the cost price*/
printf("Enter the cost price: ");
scanf("%d", &cp);
/*enter the selling price*/
printf("Enter the selling price: ");
scanf("%d", &sp);
/*if condition*/
if (sp > cp) {
/*formula to find profit*/
amount = sp - cp;
printf("profit = %d", amount);
}
/*else if condition*/
else if (cp > sp) {
/*formula to find loss*/
amount = cp - sp;
printf("loss = %d", amount);
}
/*else condition*/
else {
printf("No profit no loss\n");
}
return 0;
}
Output
输出量
First run:
Enter the cost price: 1000
Enter the selling price: 1500
profit = 500
Second run:
Enter the cost price: 2000
Enter the selling price: 1500
loss = 500
Third run:
Enter the cost price: 1000
Enter the selling price: 1000
No profit no loss
翻译自: https://www.includehelp.com/c-programs/calculate-profit-or-loss.aspx
u8的汇兑损益的计算公式