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 C program to calculate the total expenses.

/* 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 C program to calculate the total expenses.*/
#include<stdio.h>
int main()
{
	int qty, dis = 0;
	float rate, expense;

	printf("Enter Quantity: ");
	scanf("%d", &qty);

	printf("Enter Rate: ");
	scanf("%f", &rate);

	if (qty>1000)
		dis = 10;
	expense= (qty*rate) - (qty*rate*dis / 100);
	printf("\nTotal Expenses = Rs. %f", expense);
	return 0;
}

Output :
Enter Quantity: 200
Enter Rate: 100

Total Expenses = Rs. 20000.000000



Leave a comment