AnkitWebLogic

Ans 8. Write a C Program to input shopping amount and calculate discount, if amount is greater than or equals to 1000 than 15% discount is given otherwise 5%. 1

#include<stdio.h>
int main()
{
    float amount, d, n;
    printf("Enter shopping amount:");
    scanf("%f",&amount);
    if(amount>=1000)
    {
        d=amount*15/100;
    }
    else
    {
        d=amount*5/100;
    }
    printf("Discount = %.2f",d);
    n=amount-d;
    printf("\nNet Amount = %.2f",n);
    return 0;
}
Run 1:
Enter shopping amount: 2000
Discount = 300.00
Net Amount = 1700.00

Run 2:
Enter shopping amount: 505
Discount = 25.25
Net Amount = 474.75