Sunday, October 25, 2020

C program: If the purchase amount is greater than 2000 20% discount otherwise 5% discount

First Method:

#include <stdio.h>

int main() {

    float n;

    printf("Enter the purchase amount:");

    scanf("%f",&n);

    if(n>=2000)

    {

        printf("Net Pay=%.2f",n-(n*0.20));

    }

    else

    {

        printf("Net Pay=%.2f",n-(n*0.05));

    }

}

Second Method:

#include <stdio.h>

int main() {

    float n;

    printf("Enter the purchase amount:");

    scanf("%f",&n);

    if(n>=2000)

    {

        printf("Net Pay=%.2f",n*0.80);

    }

    else

    {

        printf("Net Pay=%.2f",n*0.95);

    }

}

No comments:

Post a Comment

SAP Tcodes

zme27 - Automatic STO creation mmbe - Stock Overview, Material, Batch me51n - Create Purchase Requisition me21n - Create Purchase Order me59...