Following is a program to calculate – the Total Purchase expenses with a discount :
#include <stdio.h>
int main()
{
float qty, rate, bill;
printf("Enter the quantity and rate ");
scanf("%f %f", &qty, &rate);
bill = qty * rate;
if (qty > 1000)
{
bill = bill * 0.9;
}
printf("The total expenses = Rs %f", bill);
}
Explanation:
- Input Prompt:
printf("Enter the quantity and rate: ");prompts the user to enter the quantity and rate. - Input Reading:
scanf("%f %f", &qty, &rate);reads the input values for quantity and rate. - Initial Bill Calculation:
bill = qty * rate;calculates the initial bill. - Discount Application:
if (qty > 1000) { bill = bill * 0.9; }applies a 10% discount if the quantity is greater than 1000. - Output:
printf("The total expenses = Rs %f", bill);prints the total expenses with two decimal places.
