SlideShare a Scribd company logo
1 of 16
Download to read offline
#include
#include
#include
struct product
{
int id;
char name;
int price;
int qty;
};
struct Bill
{
int pid;
char pname;
int pprice;
};
char mygetch();
int getid();
int billfileno();
void manageproduct();
void purchaseproduct();
void generatebill();
void addproduct();
void displayallproducts();
struct product findproduct(int id);
void updateproduct(int id, int qty);
char fproduct[]={"product.txt"};
char fbill[]={"bill.txt"};
int total=0;
int main()
{
File *fp;
int ch;
while(1)
{
printf("welcome product management system ");
printf("manage product ");
printf("purchase product ");
printf("generate bill ");
printf("exit ");
printf("enter your choice");
scanf("%d",&ch);
switch(ch)
{
case1:manageproduct();
break;
case2:purchaseproduct();
break;
case3:generate bill();
break;
case4:exit();
}
mygetch();
}
return 0;
int getid()
{
file *fp;
int value=0;
fp=fopen("product.txt","r");
if(fp==null)
{
fp=fopen("product.txt","w");
fprint(fp,"%d",0);
fclose(fp);
fp=fopen("product.txt","r");
}
fscanf(fp,"%d",&value);
fclose(fp);
fp=fopen("product.txt","w");
fprintf("fp,"%d",value+1);
fclose(fp);return value+1;
void manageproduct()
{
int ch
init back=0;
while(1)
{
printf("welcome product management system ");
printf("1.add new product ");
printf("2.display all products ");
printf("back ");
printf("enter your choice ");
scanf("%d",&ch);
switch(ch)
{
case1:addproduct();
break;
case2:displayallproduct();
break;
case3:(back==1)
break;
else
{
mygetch();
}
}
}
void addproduct()
{
file *fp;
struct product t1;
fp=fopen(fproduct,"ab");
t1.id=getid();
printf("enter product name");
scanf("%s",&t1.name);
printf("enter product price");
scanf("%d",&t1.price);
printf("enter product qty");
scanf("%d",&t1.qty);
fwrite(&t1,sizeof(t1),1,fp);
fclose(fp);
void dis[playallproducts()
{
file *fp;
struct product t;
int id,found=0;
fp=fopen(fproduct,"rb");
printf("product details ");
printf("idt name tqtytprice  ");
while(1)
{
fread(&t,sizeof(t),1,fp);
if(feof(fp))
{
break;
}
printf("%dt",t.id);
printf("%st",t.name);
printf("%dt",t.qty);
printf("%dt",t.price);
fclose(fp);
}
void purchase product()
char ch1,ch2;
int id;
while(1)
{
displayallproducts();
_fpurge(stdin);
printf("do u want to purchase y/n");
scanf("%c",&ch1);
if(ch1=='y')
{
file *fp;
struct bill t1;
struct product t2;
fp=fopen(fbill,"ab");
printf("enter the product id to purchase");
scanf("%d",&id);
t2=findproduct(id);
t1.pid=t2.id;
strcpy(t1.pname,t2.name);
t1.pprice=t2.price;
fwrite(&t1,sizeof(t1),1,fp);
fclose(fp);
}
_fpurge(stdin);
printf("do u want to continue y/n");
scanf("%c",&ch2);
if(ch2=='n')
{
break;
}
mygetch();
}
}
struct product findproduct(int id)
{
file *fp;
struct product t;
fp=fopen(fproduct,"rb");
if(feof(fp))
{
break;
}
if(t.id==id)
{
updateproduct(id,t.qty-1);
break;
}
}
fclose(fp);
return t;
}
void updateproduct(int id,int qty)
{
file *fp,*fp1;
struct product t,t1;
int found=0;
fp=fopen(fproduct,"rb");
fp1fopen("temp.txt","wb");
while(1)
{
fread(&t,sizeof(t),1,fp);
if(feof(fp))
{
break;
if(t.id==id)
{
found=1;
t.qty=qty;
fwrite(&t,sizeof(t),1,fp1);
else
{
fwrite(&t,sizeof(t),1,fp1);
}
}
fclose(fp);
fclose(fp1);
if(found==0)
{
printf("no record found ");
else
{
fp=fopen(fproduct,"wb");
fp1=fopen("temp.txt","rb");
while(1)
{
fread(&t,sizeof(t),1,fp1);
if(feof(fp1))
{
break;
}
fwrite(&t,sizeof(t),1,fp);
}
}
fclose(fp);
fclose(fp1);
}
vooud generatebill()
{
file *fp,*fp1;
struct Bill t;
int id ,found=0;
char ch1;
int brel=0;
char billname
fp=fopen(fbill,"rb");
printf("bill details");
printf("pro.idtpro.nametpro.price ");
while(1)
fread(&t,sizeof(t),1,fp);
if(feof(fp))
{
break;
}
printf("%dt",t.pid);
printf("%st",t.pname);
printf("%dt",t.pprice);
total=total+t.price;
}
printf("total bill amount=",total);
fclose(fp);
if(total !=0)
{
_fpurge(stdin);
printf("u want to generate final bill y/n");
scanf("%d",&ch1);
if(ch1=='y')
{
brel=billfileno();
sprintf(billname,"%s%d","",brel);
strcat(billname,".txt");
fp=fopen(fbill,"rb");
fpl=fopen(billname,"wb");
while(1)
{
fread(
Solution
#include
#include
#include
struct product
{
int id;
char name;
int price;
int qty;
};
struct Bill
{
int pid;
char pname;
int pprice;
};
char mygetch();
int getid();
int billfileno();
void manageproduct();
void purchaseproduct();
void generatebill();
void addproduct();
void displayallproducts();
struct product findproduct(int id);
void updateproduct(int id, int qty);
char fproduct[]={"product.txt"};
char fbill[]={"bill.txt"};
int total=0;
int main()
{
File *fp;
int ch;
while(1)
{
printf("welcome product management system ");
printf("manage product ");
printf("purchase product ");
printf("generate bill ");
printf("exit ");
printf("enter your choice");
scanf("%d",&ch);
switch(ch)
{
case1:manageproduct();
break;
case2:purchaseproduct();
break;
case3:generate bill();
break;
case4:exit();
}
mygetch();
}
return 0;
int getid()
{
file *fp;
int value=0;
fp=fopen("product.txt","r");
if(fp==null)
{
fp=fopen("product.txt","w");
fprint(fp,"%d",0);
fclose(fp);
fp=fopen("product.txt","r");
}
fscanf(fp,"%d",&value);
fclose(fp);
fp=fopen("product.txt","w");
fprintf("fp,"%d",value+1);
fclose(fp);return value+1;
void manageproduct()
{
int ch
init back=0;
while(1)
{
printf("welcome product management system ");
printf("1.add new product ");
printf("2.display all products ");
printf("back ");
printf("enter your choice ");
scanf("%d",&ch);
switch(ch)
{
case1:addproduct();
break;
case2:displayallproduct();
break;
case3:(back==1)
break;
else
{
mygetch();
}
}
}
void addproduct()
{
file *fp;
struct product t1;
fp=fopen(fproduct,"ab");
t1.id=getid();
printf("enter product name");
scanf("%s",&t1.name);
printf("enter product price");
scanf("%d",&t1.price);
printf("enter product qty");
scanf("%d",&t1.qty);
fwrite(&t1,sizeof(t1),1,fp);
fclose(fp);
void dis[playallproducts()
{
file *fp;
struct product t;
int id,found=0;
fp=fopen(fproduct,"rb");
printf("product details ");
printf("idt name tqtytprice  ");
while(1)
{
fread(&t,sizeof(t),1,fp);
if(feof(fp))
{
break;
}
printf("%dt",t.id);
printf("%st",t.name);
printf("%dt",t.qty);
printf("%dt",t.price);
fclose(fp);
}
void purchase product()
char ch1,ch2;
int id;
while(1)
{
displayallproducts();
_fpurge(stdin);
printf("do u want to purchase y/n");
scanf("%c",&ch1);
if(ch1=='y')
{
file *fp;
struct bill t1;
struct product t2;
fp=fopen(fbill,"ab");
printf("enter the product id to purchase");
scanf("%d",&id);
t2=findproduct(id);
t1.pid=t2.id;
strcpy(t1.pname,t2.name);
t1.pprice=t2.price;
fwrite(&t1,sizeof(t1),1,fp);
fclose(fp);
}
_fpurge(stdin);
printf("do u want to continue y/n");
scanf("%c",&ch2);
if(ch2=='n')
{
break;
}
mygetch();
}
}
struct product findproduct(int id)
{
file *fp;
struct product t;
fp=fopen(fproduct,"rb");
if(feof(fp))
{
break;
}
if(t.id==id)
{
updateproduct(id,t.qty-1);
break;
}
}
fclose(fp);
return t;
}
void updateproduct(int id,int qty)
{
file *fp,*fp1;
struct product t,t1;
int found=0;
fp=fopen(fproduct,"rb");
fp1fopen("temp.txt","wb");
while(1)
{
fread(&t,sizeof(t),1,fp);
if(feof(fp))
{
break;
if(t.id==id)
{
found=1;
t.qty=qty;
fwrite(&t,sizeof(t),1,fp1);
else
{
fwrite(&t,sizeof(t),1,fp1);
}
}
fclose(fp);
fclose(fp1);
if(found==0)
{
printf("no record found ");
else
{
fp=fopen(fproduct,"wb");
fp1=fopen("temp.txt","rb");
while(1)
{
fread(&t,sizeof(t),1,fp1);
if(feof(fp1))
{
break;
}
fwrite(&t,sizeof(t),1,fp);
}
}
fclose(fp);
fclose(fp1);
}
vooud generatebill()
{
file *fp,*fp1;
struct Bill t;
int id ,found=0;
char ch1;
int brel=0;
char billname
fp=fopen(fbill,"rb");
printf("bill details");
printf("pro.idtpro.nametpro.price ");
while(1)
fread(&t,sizeof(t),1,fp);
if(feof(fp))
{
break;
}
printf("%dt",t.pid);
printf("%st",t.pname);
printf("%dt",t.pprice);
total=total+t.price;
}
printf("total bill amount=",total);
fclose(fp);
if(total !=0)
{
_fpurge(stdin);
printf("u want to generate final bill y/n");
scanf("%d",&ch1);
if(ch1=='y')
{
brel=billfileno();
sprintf(billname,"%s%d","",brel);
strcat(billname,".txt");
fp=fopen(fbill,"rb");
fpl=fopen(billname,"wb");
while(1)
{
fread(

More Related Content

Similar to #include stdio.h#include stdlib.h#include string.hstruct.pdf

Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
C programs Set 4
C programs Set 4C programs Set 4
C programs Set 4Koshy Geoji
 
You are to write a program that computes customers bill for hisher.docx
 You are to write a program that computes customers bill for hisher.docx You are to write a program that computes customers bill for hisher.docx
You are to write a program that computes customers bill for hisher.docxajoy21
 
C programming tweak needed for a specific program.This is the comp.pdf
C programming tweak needed for a specific program.This is the comp.pdfC programming tweak needed for a specific program.This is the comp.pdf
C programming tweak needed for a specific program.This is the comp.pdfflashfashioncasualwe
 
PHP cart
PHP cartPHP cart
PHP carttumetr1
 
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIAtsushi Tadokoro
 
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdf12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdffasttracksunglass
 
--Book-java package bookStore- public class Book extends Product { (1).docx
--Book-java   package bookStore-   public class Book extends Product { (1).docx--Book-java   package bookStore-   public class Book extends Product { (1).docx
--Book-java package bookStore- public class Book extends Product { (1).docxPiersRCoThomsonw
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonYi-Lung Tsai
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdffashiionbeutycare
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++varun arora
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxDAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxtheodorelove43763
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
TypeScriptのすゝめ
TypeScriptのすゝめTypeScriptのすゝめ
TypeScriptのすゝめCASAREAL, Inc.
 

Similar to #include stdio.h#include stdlib.h#include string.hstruct.pdf (20)

Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
C programs Set 4
C programs Set 4C programs Set 4
C programs Set 4
 
You are to write a program that computes customers bill for hisher.docx
 You are to write a program that computes customers bill for hisher.docx You are to write a program that computes customers bill for hisher.docx
You are to write a program that computes customers bill for hisher.docx
 
C programming tweak needed for a specific program.This is the comp.pdf
C programming tweak needed for a specific program.This is the comp.pdfC programming tweak needed for a specific program.This is the comp.pdf
C programming tweak needed for a specific program.This is the comp.pdf
 
PHP cart
PHP cartPHP cart
PHP cart
 
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
 
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdf12.9 Program Online shopping cart (continued) (C++)This program e.pdf
12.9 Program Online shopping cart (continued) (C++)This program e.pdf
 
Qprgs
QprgsQprgs
Qprgs
 
DSA.pdf
DSA.pdfDSA.pdf
DSA.pdf
 
--Book-java package bookStore- public class Book extends Product { (1).docx
--Book-java   package bookStore-   public class Book extends Product { (1).docx--Book-java   package bookStore-   public class Book extends Product { (1).docx
--Book-java package bookStore- public class Book extends Product { (1).docx
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded Python
 
Day 1
Day 1Day 1
Day 1
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxDAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Function & Recursion in C
Function & Recursion in CFunction & Recursion in C
Function & Recursion in C
 
TypeScriptのすゝめ
TypeScriptのすゝめTypeScriptのすゝめ
TypeScriptのすゝめ
 

More from anubhavnigam2608

1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdfanubhavnigam2608
 
Seven Requirements of CTC 1 Age 2 Relationship .pdf
     Seven Requirements of CTC           1 Age     2 Relationship    .pdf     Seven Requirements of CTC           1 Age     2 Relationship    .pdf
Seven Requirements of CTC 1 Age 2 Relationship .pdfanubhavnigam2608
 
the solvents that are used to combine together to.pdf
                     the solvents that are used to combine together to.pdf                     the solvents that are used to combine together to.pdf
the solvents that are used to combine together to.pdfanubhavnigam2608
 
The most simple property to calculate this is Ka.pdf
                     The most simple property to calculate this is Ka.pdf                     The most simple property to calculate this is Ka.pdf
The most simple property to calculate this is Ka.pdfanubhavnigam2608
 
The images of the compounds are not visible. Kin.pdf
                     The images of the compounds are not visible.  Kin.pdf                     The images of the compounds are not visible.  Kin.pdf
The images of the compounds are not visible. Kin.pdfanubhavnigam2608
 
Step1 Moles of water produced =18 Step2 The init.pdf
                     Step1 Moles of water produced =18  Step2 The init.pdf                     Step1 Moles of water produced =18  Step2 The init.pdf
Step1 Moles of water produced =18 Step2 The init.pdfanubhavnigam2608
 
Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
Sorry. SnO2 is amphoteric. This one is a tricky o.pdfanubhavnigam2608
 
scientific synonyms for height may be peak or tal.pdf
                     scientific synonyms for height may be peak or tal.pdf                     scientific synonyms for height may be peak or tal.pdf
scientific synonyms for height may be peak or tal.pdfanubhavnigam2608
 
R = k[NOCl2][NO] Molecularity = 2 .pdf
                     R = k[NOCl2][NO]  Molecularity = 2               .pdf                     R = k[NOCl2][NO]  Molecularity = 2               .pdf
R = k[NOCl2][NO] Molecularity = 2 .pdfanubhavnigam2608
 
In general, they are alkenes attached to electron.pdf
                     In general, they are alkenes attached to electron.pdf                     In general, they are alkenes attached to electron.pdf
In general, they are alkenes attached to electron.pdfanubhavnigam2608
 
Group 11 has three elements namely, Cu, Ag and Au.pdf
                     Group 11 has three elements namely, Cu, Ag and Au.pdf                     Group 11 has three elements namely, Cu, Ag and Au.pdf
Group 11 has three elements namely, Cu, Ag and Au.pdfanubhavnigam2608
 
Cu, (H2), Zn, Mg Activity series basedon hyd.pdf
                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf
Cu, (H2), Zn, Mg Activity series basedon hyd.pdfanubhavnigam2608
 
answewrSolutionanswewr.pdf
answewrSolutionanswewr.pdfanswewrSolutionanswewr.pdf
answewrSolutionanswewr.pdfanubhavnigam2608
 
When a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdfWhen a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdfanubhavnigam2608
 
Calcium metal reacts with liquid water to produce.pdf
                     Calcium metal reacts with liquid water to produce.pdf                     Calcium metal reacts with liquid water to produce.pdf
Calcium metal reacts with liquid water to produce.pdfanubhavnigam2608
 
The mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdfThe mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdfanubhavnigam2608
 

More from anubhavnigam2608 (20)

1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf  1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
1.KClO(3) ---- Potassium chlorate 2.H(2)SO(2) ------ sulphurous acid.pdf
 
Seven Requirements of CTC 1 Age 2 Relationship .pdf
     Seven Requirements of CTC           1 Age     2 Relationship    .pdf     Seven Requirements of CTC           1 Age     2 Relationship    .pdf
Seven Requirements of CTC 1 Age 2 Relationship .pdf
 
the solvents that are used to combine together to.pdf
                     the solvents that are used to combine together to.pdf                     the solvents that are used to combine together to.pdf
the solvents that are used to combine together to.pdf
 
The most simple property to calculate this is Ka.pdf
                     The most simple property to calculate this is Ka.pdf                     The most simple property to calculate this is Ka.pdf
The most simple property to calculate this is Ka.pdf
 
The images of the compounds are not visible. Kin.pdf
                     The images of the compounds are not visible.  Kin.pdf                     The images of the compounds are not visible.  Kin.pdf
The images of the compounds are not visible. Kin.pdf
 
Step1 Moles of water produced =18 Step2 The init.pdf
                     Step1 Moles of water produced =18  Step2 The init.pdf                     Step1 Moles of water produced =18  Step2 The init.pdf
Step1 Moles of water produced =18 Step2 The init.pdf
 
Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf                     Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
Sorry. SnO2 is amphoteric. This one is a tricky o.pdf
 
SO2 Solu.pdf
                     SO2                                      Solu.pdf                     SO2                                      Solu.pdf
SO2 Solu.pdf
 
scientific synonyms for height may be peak or tal.pdf
                     scientific synonyms for height may be peak or tal.pdf                     scientific synonyms for height may be peak or tal.pdf
scientific synonyms for height may be peak or tal.pdf
 
R = k[NOCl2][NO] Molecularity = 2 .pdf
                     R = k[NOCl2][NO]  Molecularity = 2               .pdf                     R = k[NOCl2][NO]  Molecularity = 2               .pdf
R = k[NOCl2][NO] Molecularity = 2 .pdf
 
In general, they are alkenes attached to electron.pdf
                     In general, they are alkenes attached to electron.pdf                     In general, they are alkenes attached to electron.pdf
In general, they are alkenes attached to electron.pdf
 
I, II S.pdf
                     I, II                                       S.pdf                     I, II                                       S.pdf
I, II S.pdf
 
Group 11 has three elements namely, Cu, Ag and Au.pdf
                     Group 11 has three elements namely, Cu, Ag and Au.pdf                     Group 11 has three elements namely, Cu, Ag and Au.pdf
Group 11 has three elements namely, Cu, Ag and Au.pdf
 
Cu, (H2), Zn, Mg Activity series basedon hyd.pdf
                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf                     Cu, (H2), Zn, Mg  Activity series basedon hyd.pdf
Cu, (H2), Zn, Mg Activity series basedon hyd.pdf
 
answewrSolutionanswewr.pdf
answewrSolutionanswewr.pdfanswewrSolutionanswewr.pdf
answewrSolutionanswewr.pdf
 
cis- So.pdf
                     cis-                                       So.pdf                     cis-                                       So.pdf
cis- So.pdf
 
When a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdfWhen a compound is completely oxidized with oxygen, the products wil.pdf
When a compound is completely oxidized with oxygen, the products wil.pdf
 
Calcium metal reacts with liquid water to produce.pdf
                     Calcium metal reacts with liquid water to produce.pdf                     Calcium metal reacts with liquid water to produce.pdf
Calcium metal reacts with liquid water to produce.pdf
 
two;Solutiontwo;.pdf
two;Solutiontwo;.pdftwo;Solutiontwo;.pdf
two;Solutiontwo;.pdf
 
The mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdfThe mineralogical and structural adjustment of solid rocks to physic.pdf
The mineralogical and structural adjustment of solid rocks to physic.pdf
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 

Recently uploaded (20)

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 

#include stdio.h#include stdlib.h#include string.hstruct.pdf

  • 1. #include #include #include struct product { int id; char name; int price; int qty; }; struct Bill { int pid; char pname; int pprice; }; char mygetch(); int getid(); int billfileno(); void manageproduct(); void purchaseproduct(); void generatebill(); void addproduct(); void displayallproducts(); struct product findproduct(int id); void updateproduct(int id, int qty); char fproduct[]={"product.txt"}; char fbill[]={"bill.txt"}; int total=0; int main() { File *fp; int ch; while(1) {
  • 2. printf("welcome product management system "); printf("manage product "); printf("purchase product "); printf("generate bill "); printf("exit "); printf("enter your choice"); scanf("%d",&ch); switch(ch) { case1:manageproduct(); break; case2:purchaseproduct(); break; case3:generate bill(); break; case4:exit(); } mygetch(); } return 0; int getid() { file *fp; int value=0; fp=fopen("product.txt","r"); if(fp==null) { fp=fopen("product.txt","w"); fprint(fp,"%d",0); fclose(fp); fp=fopen("product.txt","r"); } fscanf(fp,"%d",&value); fclose(fp); fp=fopen("product.txt","w"); fprintf("fp,"%d",value+1);
  • 3. fclose(fp);return value+1; void manageproduct() { int ch init back=0; while(1) { printf("welcome product management system "); printf("1.add new product "); printf("2.display all products "); printf("back "); printf("enter your choice "); scanf("%d",&ch); switch(ch) { case1:addproduct(); break; case2:displayallproduct(); break; case3:(back==1) break; else { mygetch(); } } } void addproduct() { file *fp; struct product t1; fp=fopen(fproduct,"ab"); t1.id=getid(); printf("enter product name"); scanf("%s",&t1.name); printf("enter product price");
  • 4. scanf("%d",&t1.price); printf("enter product qty"); scanf("%d",&t1.qty); fwrite(&t1,sizeof(t1),1,fp); fclose(fp); void dis[playallproducts() { file *fp; struct product t; int id,found=0; fp=fopen(fproduct,"rb"); printf("product details "); printf("idt name tqtytprice "); while(1) { fread(&t,sizeof(t),1,fp); if(feof(fp)) { break; } printf("%dt",t.id); printf("%st",t.name); printf("%dt",t.qty); printf("%dt",t.price); fclose(fp); } void purchase product() char ch1,ch2; int id; while(1) { displayallproducts(); _fpurge(stdin); printf("do u want to purchase y/n"); scanf("%c",&ch1); if(ch1=='y')
  • 5. { file *fp; struct bill t1; struct product t2; fp=fopen(fbill,"ab"); printf("enter the product id to purchase"); scanf("%d",&id); t2=findproduct(id); t1.pid=t2.id; strcpy(t1.pname,t2.name); t1.pprice=t2.price; fwrite(&t1,sizeof(t1),1,fp); fclose(fp); } _fpurge(stdin); printf("do u want to continue y/n"); scanf("%c",&ch2); if(ch2=='n') { break; } mygetch(); } } struct product findproduct(int id) { file *fp; struct product t; fp=fopen(fproduct,"rb"); if(feof(fp)) { break; } if(t.id==id) { updateproduct(id,t.qty-1);
  • 6. break; } } fclose(fp); return t; } void updateproduct(int id,int qty) { file *fp,*fp1; struct product t,t1; int found=0; fp=fopen(fproduct,"rb"); fp1fopen("temp.txt","wb"); while(1) { fread(&t,sizeof(t),1,fp); if(feof(fp)) { break; if(t.id==id) { found=1; t.qty=qty; fwrite(&t,sizeof(t),1,fp1); else { fwrite(&t,sizeof(t),1,fp1); } } fclose(fp); fclose(fp1); if(found==0) { printf("no record found "); else {
  • 7. fp=fopen(fproduct,"wb"); fp1=fopen("temp.txt","rb"); while(1) { fread(&t,sizeof(t),1,fp1); if(feof(fp1)) { break; } fwrite(&t,sizeof(t),1,fp); } } fclose(fp); fclose(fp1); } vooud generatebill() { file *fp,*fp1; struct Bill t; int id ,found=0; char ch1; int brel=0; char billname fp=fopen(fbill,"rb"); printf("bill details"); printf("pro.idtpro.nametpro.price "); while(1) fread(&t,sizeof(t),1,fp); if(feof(fp)) { break; } printf("%dt",t.pid); printf("%st",t.pname); printf("%dt",t.pprice); total=total+t.price;
  • 8. } printf("total bill amount=",total); fclose(fp); if(total !=0) { _fpurge(stdin); printf("u want to generate final bill y/n"); scanf("%d",&ch1); if(ch1=='y') { brel=billfileno(); sprintf(billname,"%s%d","",brel); strcat(billname,".txt"); fp=fopen(fbill,"rb"); fpl=fopen(billname,"wb"); while(1) { fread( Solution #include #include #include struct product { int id; char name; int price; int qty; }; struct Bill { int pid; char pname; int pprice;
  • 9. }; char mygetch(); int getid(); int billfileno(); void manageproduct(); void purchaseproduct(); void generatebill(); void addproduct(); void displayallproducts(); struct product findproduct(int id); void updateproduct(int id, int qty); char fproduct[]={"product.txt"}; char fbill[]={"bill.txt"}; int total=0; int main() { File *fp; int ch; while(1) { printf("welcome product management system "); printf("manage product "); printf("purchase product "); printf("generate bill "); printf("exit "); printf("enter your choice"); scanf("%d",&ch); switch(ch) { case1:manageproduct(); break; case2:purchaseproduct(); break; case3:generate bill(); break; case4:exit();
  • 10. } mygetch(); } return 0; int getid() { file *fp; int value=0; fp=fopen("product.txt","r"); if(fp==null) { fp=fopen("product.txt","w"); fprint(fp,"%d",0); fclose(fp); fp=fopen("product.txt","r"); } fscanf(fp,"%d",&value); fclose(fp); fp=fopen("product.txt","w"); fprintf("fp,"%d",value+1); fclose(fp);return value+1; void manageproduct() { int ch init back=0; while(1) { printf("welcome product management system "); printf("1.add new product "); printf("2.display all products "); printf("back "); printf("enter your choice "); scanf("%d",&ch); switch(ch) { case1:addproduct();
  • 11. break; case2:displayallproduct(); break; case3:(back==1) break; else { mygetch(); } } } void addproduct() { file *fp; struct product t1; fp=fopen(fproduct,"ab"); t1.id=getid(); printf("enter product name"); scanf("%s",&t1.name); printf("enter product price"); scanf("%d",&t1.price); printf("enter product qty"); scanf("%d",&t1.qty); fwrite(&t1,sizeof(t1),1,fp); fclose(fp); void dis[playallproducts() { file *fp; struct product t; int id,found=0; fp=fopen(fproduct,"rb"); printf("product details "); printf("idt name tqtytprice "); while(1) { fread(&t,sizeof(t),1,fp);
  • 12. if(feof(fp)) { break; } printf("%dt",t.id); printf("%st",t.name); printf("%dt",t.qty); printf("%dt",t.price); fclose(fp); } void purchase product() char ch1,ch2; int id; while(1) { displayallproducts(); _fpurge(stdin); printf("do u want to purchase y/n"); scanf("%c",&ch1); if(ch1=='y') { file *fp; struct bill t1; struct product t2; fp=fopen(fbill,"ab"); printf("enter the product id to purchase"); scanf("%d",&id); t2=findproduct(id); t1.pid=t2.id; strcpy(t1.pname,t2.name); t1.pprice=t2.price; fwrite(&t1,sizeof(t1),1,fp); fclose(fp); } _fpurge(stdin); printf("do u want to continue y/n");
  • 13. scanf("%c",&ch2); if(ch2=='n') { break; } mygetch(); } } struct product findproduct(int id) { file *fp; struct product t; fp=fopen(fproduct,"rb"); if(feof(fp)) { break; } if(t.id==id) { updateproduct(id,t.qty-1); break; } } fclose(fp); return t; } void updateproduct(int id,int qty) { file *fp,*fp1; struct product t,t1; int found=0; fp=fopen(fproduct,"rb"); fp1fopen("temp.txt","wb"); while(1) { fread(&t,sizeof(t),1,fp);
  • 14. if(feof(fp)) { break; if(t.id==id) { found=1; t.qty=qty; fwrite(&t,sizeof(t),1,fp1); else { fwrite(&t,sizeof(t),1,fp1); } } fclose(fp); fclose(fp1); if(found==0) { printf("no record found "); else { fp=fopen(fproduct,"wb"); fp1=fopen("temp.txt","rb"); while(1) { fread(&t,sizeof(t),1,fp1); if(feof(fp1)) { break; } fwrite(&t,sizeof(t),1,fp); } } fclose(fp); fclose(fp1); } vooud generatebill()
  • 15. { file *fp,*fp1; struct Bill t; int id ,found=0; char ch1; int brel=0; char billname fp=fopen(fbill,"rb"); printf("bill details"); printf("pro.idtpro.nametpro.price "); while(1) fread(&t,sizeof(t),1,fp); if(feof(fp)) { break; } printf("%dt",t.pid); printf("%st",t.pname); printf("%dt",t.pprice); total=total+t.price; } printf("total bill amount=",total); fclose(fp); if(total !=0) { _fpurge(stdin); printf("u want to generate final bill y/n"); scanf("%d",&ch1); if(ch1=='y') { brel=billfileno(); sprintf(billname,"%s%d","",brel); strcat(billname,".txt"); fp=fopen(fbill,"rb"); fpl=fopen(billname,"wb"); while(1)