a shop gives a discount of 10% if the cost of purchased quantity is more than 1000.Ask a user for the quantity supposing that one unit cost 100 print the total cost for user
Answers
Given:
A shop gives a discount of 10% if the cost of purchased quantity is more than 1000.
To find:
Print the total cost for user
Solution:
C program:
#include<stdio.h>
int main(){
int quantity;
float totalcost;
Printf(“enter quantity”);
Scanf(“%d”,&quantity);
If(quantity*100>1000)
{
totalcost= ((quantity*100)-((10*(quantity*100)/100))
//SUBTRACTING DISCOUNT FROM ORIGINAL AMOUNT
}
else
{
totalcost=quantity*100;
//CALUCLATING TOTAL COST 100 PER UNIT
}
printf(“the total cost is %f”,totalcost);
return 0;
}
OUTPUT:
Enter quantity 20
The total cost is 1800
Explanation:
QUANTITY=20
SO 20100=2000
AS 2000 IS GREATER THAN 1000 WE GIVE 10% DISCOUNT
SO
10% IN 2000 IS
SO 10% IN 2000 IS 200
WE CALUCLATE TOTALCOST BY SUBTRACTING
ACCTUAL COST-DISCOUNT COST
SO 2000-200=1800
1800 IS THE TOTALCOST