Q. Write a C program to read quantity and price for each item. Calculate the total expenses, and if the quantity is more than 1000 than giving discount is 20%.
Ans.
/*Calculate the total expenses*/
#include<stdio.h>
#include<conio.h>
void main()
{
int quant,dis=0;
float tot,rate;
clrscr();
clrscr();
printf("Enter quantity : ");
scanf("%d",&quant);
pirntf("\nEnter rate : ");
scanf("%f",&rate);
if(quant>1000)
dis=20;
tot=(quant*rate)-(quent*rate*dis/100);
pirntf("\nTotal expenses = %f",tot);
getch();
}
Output :
Enter quantity :750
Enter rate : 35.54
Total expenses = 25905.000000
Enter quantity : 1450
Enter rate : 9.50
Total expenses = 12397.500000
No comments:
Post a Comment