While purchasing certain items, a discount of 10% is offered if the quantity
purchased is more than 1000. If quantity and price per item are input through the
keyboard, create a program on it
#include <stdio.h>
int main()
{
float quant, prc, total, discount;
total = 0;
discount = 0;
printf("Enter quantity: ");
scanf("%f", &quant);
printf("Enter price per item: ");
scanf("%f", &prc);
if (quant > 1000)
{
discount = (quant * prc) * 0.1;
total = (quant * prc) - discount;
printf("\n\nTotal: %.2f\n", (quant * prc));
printf("Discount: %.2f\n", discount);
printf("\nTotal with discount: %.2f\n", total);
}
else
{
total = quant * prc;
printf("\nTotal: %.2f\n", total);
}
getchar();
}
Comments
Leave a comment