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, write a program and a flowchart to calculate the total expenses.
#include <stdio.h>
int main() {
int quantity;
double price;
double total_expense;
double discount;
printf("How many items do you want to purchase: ");
scanf("%d", &quantity);
printf("Enter a price per item: ");
scanf("%lf", &price);
total_expense = quantity * price;
if (quantity > 1000) {
discount = 0.1 * total_expense;
total_expense -= discount;
}
printf("The total expense is %.lf\n", total_expense);
return 0;
}
Comments
Leave a comment