u8的汇兑损益的计算公式_C程序计算损益

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的汇兑损益的计算公式

解释这段代码逻辑 void TPS929120_CorrespondDriverIndexFrmtypeSts(uint8 u8_bus_id_in,uint8 u8_frmtype) { uint8 u8_ValidDrvNum = 0; uint8 u8_RepeatRnblDrvNum = 0; u8_RepeatRnblDrvNum = un_BusShareRam[u8_bus_id_in].st_Tps929120.u8_RepeatRnblMatrixDriverNumber; u8_ValidDrvNum = un_BusShareRam[u8_bus_id_in].st_Tps929120.u8_ValidMatrixDriverNumber; if(un_BusShareRam[u8_bus_id_in].st_Tps929120.st_DrvRnblSts.u8_Refresh_Driver_index == 0) { if( (u8_ValidDrvNum - un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount < u8_RepeatRnblDrvNum) && \ (u8_ValidDrvNum - un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount > 0) ) { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltFrmtypeCount = 0; un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_SendCpltDrvCounter = 0; if(u8_frmtype == TPS929120_PWMFRMMODE) { if(g_u8_Tps92912xFixedOperationAddressflg == 1) { if(TPS929120_FIXEDCHIPNUM == 2) { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = u8_RepeatRnblDrvNum; } else if(TPS929120_FIXEDCHIPNUM == 1) { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = TPS929120_FIXEDCHIPNUM + \ (u8_ValidDrvNum - un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount); } } else { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = \ (u8_ValidDrvNum - un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount) ; } } else { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = \ (u8_ValidDrvNum - un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount) ; } } else if(0 == (u8_ValidDrvNum - un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount)) { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltFrmtypeCount = 0; un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_SendCpltDrvCounter = 0; un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltDrvCount = 0; if(u8_ValidDrvNum >= u8_RepeatRnblDrvNum) { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = u8_RepeatRnblDrvNum; } else { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = u8_ValidDrvNum; } } else { un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_CpltFrmtypeCount = 0; un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_SendCpltDrvCounter = 0; un_BusShareRam[u8_bus_id_in].st_Tps929120.st_FrmtypeSts[u8_frmtype].u8_FrmPackDrvNumPerRnbl = u8_RepeatRnblDrvNum; } un_BusShareRam[u8_bus_id_in].st_Tps929120.st_DrvRnblSts.u8_Refresh_Driver_index = 1; } else { /NO CODE/ } }
04-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值