Computer Science, asked by Mounikakosuri777, 1 year ago

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
clrscr();
char name[20],date[40],ch1='y',ch2='y',pro[100];
float rate,cost=0.0,total=0.0,c[100];
int bill,sno=0,quantity,q[100],product,i;
FILE *fp;
fp=fopen("f.c","r");
while(ch1=='y')
{
printf("ENTER COUSTOMER'S NAME ");
scanf("%s",&name);
printf("\nENTER BILL NUMBER ");
scanf("%d",&bill);
printf("\nENTER DATE ");
scanf("%s",&date);
printf("\nENTER NAME OF THE PRODUCT ");
printf("\nPLEASE\nPRESS 1 FOR SOAP \nPRESS 2 FOR BRUSH \nPRESS 3 FOR PASTE \nPRESS 4 FOR RING \nPRESS 5 FOR NOTE BOOK\n ");
ch2='y';
while(ch2=='y')
{
printf("\nENTER YOUR CHOICE ");
scanf("%d",&product);
switch(product)
{
case 1:
printf("\nENTER QUANTITY ");
scanf("%d",&quantity);
rate=20;
cost=quantity*20;
sno++;
c[sno]=cost;
total=total+cost;
pro[sno]=product;
q[sno]=quantity;
break;
case 2:
printf("\nENTER QUANTITY");
scanf("%d",&quantity);
rate=5;
sno++;
cost=quantity*5;
c[sno]=cost;
total=total+cost;
pro[sno]=product;
q[sno]=quantity;
break;
case 3:
printf("\nENTER QUANTITY");
scanf("%d",&quantity);
rate=30;
sno++;
cost=quantity*30;
c[sno]=cost;
total=total+cost;
pro[sno]=product;
q[sno]=quantity;
c[sno]=cost;
break;
case 4:
printf("\nENTER QUANTITY");
scanf("%d",&quantity);
rate=10;
sno++;
cost=quantity*10;
c[sno]=cost;
total=total+cost;
pro[sno]=product;
q[sno]=quantity;
break;
case 5:
printf("\nENTER QUANTITY");
scanf("%d",&quantity);
rate=15;
sno++;
cost=quantity*15;
c[sno]=cost;
total=total+cost;
pro[sno]=product;
q[sno]=quantity;
break;
default:
printf("\nINVALID RESPONSE");
}
printf(" \nANY MORE PRODUCT PRESS 'y' AND 'n' FOR NO");
fflush(stdin);
scanf("%c",&ch2);
}
fclose(fp);
fp=fopen("f.c","app");
printf("\nCOUSTOMER'S NAME:%s",name);
printf("\tBILL NO.%d",bill);
printf("\nDATE%s",date);
printf("\nS NO.\tPRODUCT\tRATE\tQUANTITY\tCOST");
for(i=1;i<=sno;i++)
{
printf("\n%d",i);
if(pro[i]==1)
{
printf("\tSOAP\t");
printf("20");
}
else if(pro[i]==2)
{
printf("\tBRUSH\t");
printf("5");
}
else if(pro[i]==3)
{
printf("\tPASTE\t");
printf("30");
}
else if(pro[i]==4)
{
printf("\tRING\t");
printf("10");
}
else
{
printf("\tNOTEBOOK");
printf("15");
}
printf("\t%d",q[i]);
printf("\t\t%f",c[i]);
printf("\n");
}
printf("\nTOTAL%f",total);
printf("\n");
printf("\nNEXT CUSTOMER");
printf("\nPRESS 'y' TO CONTINUE ");
fflush(stdin);
scanf("%c",&ch1);
for(i=1;i<=sno;i++)
{
pro[i]=0;
q[i]=0;
c[i]=0;
}
fclose(fp);
return 0;
}​

Answers

Answered by yaruq678
0

Answer:

Hi mate please correct your question amd mark brainliest itni mehnat sey neeche aaya hoon

Similar questions