SlideShare a Scribd company logo
1 of 9
Download to read offline
C++ PROGRAM
This program builds on the code below:
#include
#include
#include "shirtType.h"
using namespace std;
void getInput(shirtType s[],ifstream& infile, int& numShirts);
int main()
{
int numShirts;
shirtType shirts[500];
ifstream infile;
infile.open("h:shirtlab.txt");
getInput(shirts,infile,numShirts);
for(int i =0; i>id;
infile.ignore(100,' ');
getline(infile,c);
infile>>size>>p>>q;
while(infile)
{
s[index].setAll(id, c, size, p, q);
index++;
infile>>id;
infile.ignore(100,' ');
getline(infile,c);
infile>>size>>p>>q;
}
numShirts=index;
}
See also the description of the class shirtType below:
#include
#include
using namespace std;
class shirtType
{
private:
int shirtID;
string color;
string size;
double price;
int quantity;
public:
void setAll(int i,string c,string s, double p, int q);
void print() const;
void newQuan();
shirtType();
shirtType(int,string,string,double,int);
};
shirtType::shirtType(int i,string c,string s, double p, int q)
{
color = c;
size = s;
if(i>0)
shirtID=i;
else
shirtID=0;
if(p>0.0)
price = p;
else
price=0.0;
if (q>=0)
quantity=q;
else
quantity = 0;
}
shirtType::shirtType()
{
shirtID=0;
color="";
size="";
price=0.0;
quantity=0;
}
void shirtType::setAll(int i,string c,string s, double p, int q)
{
color = c;
size = s;
if(i>0)
shirtID=i;
else
shirtID=0;
if(p>0.0)
price = p;
else
price=0.0;
if (q>=0)
quantity=q;
else
quantity = 0;
}
void shirtType::newQuan()
{
cout<<"Enter the new quantity of shirts: "<>quantity;
}
void shirtType::print() const
{
cout<<"Shirt ID: "<
Solution
#include
#include
struct node
{
int data;
struct node *next;
}*head;
void append(int nkkm)
{
struct node *temp,*right;
temp= (struct node *)malloc(sizeof(struct node));
temp->data=nkkm;
right=(struct node *)head;
while(right->next != NULL)
right=right->next;
right->next =temp;
right=temp;
right->next=NULL;
}
void add( int nkkm )
{
struct node *temp;
temp=(struct node *)malloc(sizeof(struct node));
temp->data=nkkm;
if (head== NULL)
{
head=temp;
head->next=NULL;
}
else
{
temp->next=head;
head=temp;
}
}
void addafter(int nkkm, int loc)
{
int i;
struct node *temp,*left,*right;
right=head;
for(i=1;inext;
}
temp=(struct node *)malloc(sizeof(struct node));
temp->data=nkkm;
left->next=temp;
left=temp;
left->next=right;
return;
}
void addaShirt(int nkkm)
{
int c=0;
struct node *temp;
temp=head;
if(temp==NULL)
{
add(nkkm);
}
else
{
while(temp!=NULL)
{
if(temp->datanext;
}
if(c==0)
add(nkkm);
else if(cdata==nkkm)
{
if(temp==head)
{
head=temp->next;
free(temp);
return 1;
}
else
{
prev->next=temp->next;
free(temp);
return 1;
}
}
else
{
prev=temp;
temp= temp->next;
}
}
return 0;
}
void display(struct node *r)
{
r=head;
if(r==NULL)
{
return;
}
while(r!=NULL)
{
printf("%d ",r->data);
r=r->next;
}
printf(" ");
}
int count()
{
struct node *n;
int c=0;
n=head;
while(n!=NULL)
{
n=n->next;
c++;
}
return c;
}
int main()
{
int i,nkkm;
struct node *n;
head=NULL;
while(1)
{
printf("1.Add a shirt ");
printf("2.Sell a shirt ");
printf("3.Restock a shirt ");
printf("4.Print a list of all shirts  ");
printf("5.Quit ");
printf("Enter your choice : ");
if(scanf("%d",&i)<=0){
printf("Enter only an Integer ");
exit(0);
} else {
switch(i)
{
case 1: printf("Enter the number to addaShirt : ");
scanf("%d",&nkkm);
addaShirt(nkkm);
break;
case 2: if(head==NULL)
{
printf("List is Empty ");
}
else
{
printf("Element(s) in the list are : ");
}
display(n);
break;
case 3: printf("Size of the list is %d ",count());
break;
case 4: if(head==NULL)
printf("List is Empty ");
else{
printf("Enter the number to delete : ");
scanf("%d",&nkkm);
if(delete(nkkm))
printf("%d deleted successfully ",nkkm);
else
printf("%d not found in the list ",nkkm);
}
break;
case 5: return 0;
default: printf("Invalid option ");
}
}
}
return 0;
}

More Related Content

Similar to C++ PROGRAMThis program builds on the code below#include iostr.pdf

C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
herminaherman
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
apleather
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 

Similar to C++ PROGRAMThis program builds on the code below#include iostr.pdf (20)

DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
C programming
C programmingC programming
C programming
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
 
C programms
C programmsC programms
C programms
 
C Programming Lab.pdf
C Programming Lab.pdfC Programming Lab.pdf
C Programming Lab.pdf
 
RAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAMRAILWAY RESERWATION PROJECT PROGRAM
RAILWAY RESERWATION PROJECT PROGRAM
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
 
C faq pdf
C faq pdfC faq pdf
C faq pdf
 
Railway reservation
Railway reservationRailway reservation
Railway reservation
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf#include stdio.h#include stdlib.h#include string.h#inclu.pdf
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Twitter sentiment analysis for cryptoassets
Twitter sentiment analysis for cryptoassets Twitter sentiment analysis for cryptoassets
Twitter sentiment analysis for cryptoassets
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
Cd practical file (1) start se
Cd practical file (1) start seCd practical file (1) start se
Cd practical file (1) start se
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
Pnno
PnnoPnno
Pnno
 

More from irshadoptical

i need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfi need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdf
irshadoptical
 
Help!! Which of the following correctly lists the simple molecules t.pdf
Help!! Which of the following correctly lists the simple molecules t.pdfHelp!! Which of the following correctly lists the simple molecules t.pdf
Help!! Which of the following correctly lists the simple molecules t.pdf
irshadoptical
 
You are in charge of the investigation regarding possible exposur.pdf
You are in charge of the investigation regarding possible exposur.pdfYou are in charge of the investigation regarding possible exposur.pdf
You are in charge of the investigation regarding possible exposur.pdf
irshadoptical
 
Which of the following is not a product of the light reactions of ph.pdf
Which of the following is not a product of the light reactions of ph.pdfWhich of the following is not a product of the light reactions of ph.pdf
Which of the following is not a product of the light reactions of ph.pdf
irshadoptical
 
Write a line of code to create a Print Writer to write to the file .pdf
Write a line of code to create a Print Writer to write to the file .pdfWrite a line of code to create a Print Writer to write to the file .pdf
Write a line of code to create a Print Writer to write to the file .pdf
irshadoptical
 

More from irshadoptical (20)

In practice, a RAM is used to simulate the operation of a stack by m.pdf
In practice, a RAM is used to simulate the operation of a stack by m.pdfIn practice, a RAM is used to simulate the operation of a stack by m.pdf
In practice, a RAM is used to simulate the operation of a stack by m.pdf
 
i need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdfi need help to edit the two methods below so that i can have them wo.pdf
i need help to edit the two methods below so that i can have them wo.pdf
 
Help!! Which of the following correctly lists the simple molecules t.pdf
Help!! Which of the following correctly lists the simple molecules t.pdfHelp!! Which of the following correctly lists the simple molecules t.pdf
Help!! Which of the following correctly lists the simple molecules t.pdf
 
How does feasibility differ in an agile environment in comparison to.pdf
How does feasibility differ in an agile environment in comparison to.pdfHow does feasibility differ in an agile environment in comparison to.pdf
How does feasibility differ in an agile environment in comparison to.pdf
 
describe a real-life example of selection against a homozygous reces.pdf
describe a real-life example of selection against a homozygous reces.pdfdescribe a real-life example of selection against a homozygous reces.pdf
describe a real-life example of selection against a homozygous reces.pdf
 
Define a motor unit. What roles do motor units play in graded contrac.pdf
Define a motor unit. What roles do motor units play in graded contrac.pdfDefine a motor unit. What roles do motor units play in graded contrac.pdf
Define a motor unit. What roles do motor units play in graded contrac.pdf
 
An antibody is a protein that has which level of protein structure .pdf
An antibody is a protein that has which level of protein structure  .pdfAn antibody is a protein that has which level of protein structure  .pdf
An antibody is a protein that has which level of protein structure .pdf
 
You are in charge of the investigation regarding possible exposur.pdf
You are in charge of the investigation regarding possible exposur.pdfYou are in charge of the investigation regarding possible exposur.pdf
You are in charge of the investigation regarding possible exposur.pdf
 
Which of the following is not a product of the light reactions of ph.pdf
Which of the following is not a product of the light reactions of ph.pdfWhich of the following is not a product of the light reactions of ph.pdf
Which of the following is not a product of the light reactions of ph.pdf
 
Write a line of code to create a Print Writer to write to the file .pdf
Write a line of code to create a Print Writer to write to the file .pdfWrite a line of code to create a Print Writer to write to the file .pdf
Write a line of code to create a Print Writer to write to the file .pdf
 
what is the difference bettween cotranslational import and posttrans.pdf
what is the difference bettween cotranslational import and posttrans.pdfwhat is the difference bettween cotranslational import and posttrans.pdf
what is the difference bettween cotranslational import and posttrans.pdf
 
What is the meaning of critical periods in neonatal development Wha.pdf
What is the meaning of critical periods in neonatal development Wha.pdfWhat is the meaning of critical periods in neonatal development Wha.pdf
What is the meaning of critical periods in neonatal development Wha.pdf
 
What are the major differences between foreign bonds and Eurobonds .pdf
What are the major differences between foreign bonds and Eurobonds .pdfWhat are the major differences between foreign bonds and Eurobonds .pdf
What are the major differences between foreign bonds and Eurobonds .pdf
 
What is meant by ecological fallacySolutionAnswerThe term .pdf
What is meant by ecological fallacySolutionAnswerThe term .pdfWhat is meant by ecological fallacySolutionAnswerThe term .pdf
What is meant by ecological fallacySolutionAnswerThe term .pdf
 
What are the two main branches of Non-Euclidean Geometry What is the.pdf
What are the two main branches of Non-Euclidean Geometry What is the.pdfWhat are the two main branches of Non-Euclidean Geometry What is the.pdf
What are the two main branches of Non-Euclidean Geometry What is the.pdf
 
By what transport method does oxygen enter the blood from the alveol.pdf
By what transport method does oxygen enter the blood from the alveol.pdfBy what transport method does oxygen enter the blood from the alveol.pdf
By what transport method does oxygen enter the blood from the alveol.pdf
 
All of these are examples of evidence used to support the hypothesis.pdf
All of these are examples of evidence used to support the hypothesis.pdfAll of these are examples of evidence used to support the hypothesis.pdf
All of these are examples of evidence used to support the hypothesis.pdf
 
A 28 year-old biologist makes a trip to study life forms in a distan.pdf
A 28 year-old biologist makes a trip to study life forms in a distan.pdfA 28 year-old biologist makes a trip to study life forms in a distan.pdf
A 28 year-old biologist makes a trip to study life forms in a distan.pdf
 
4. Name the following compounds CO2 CH CH3 CH20H CH3COOH 5. Water ha.pdf
4. Name the following compounds CO2 CH CH3 CH20H CH3COOH 5. Water ha.pdf4. Name the following compounds CO2 CH CH3 CH20H CH3COOH 5. Water ha.pdf
4. Name the following compounds CO2 CH CH3 CH20H CH3COOH 5. Water ha.pdf
 
4. When examining whether group differences occur on more than one d.pdf
4. When examining whether group differences occur on more than one d.pdf4. When examining whether group differences occur on more than one d.pdf
4. When examining whether group differences occur on more than one d.pdf
 

Recently uploaded

會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Recently uploaded (20)

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
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
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
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
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
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
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
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
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
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 

C++ PROGRAMThis program builds on the code below#include iostr.pdf

  • 1. C++ PROGRAM This program builds on the code below: #include #include #include "shirtType.h" using namespace std; void getInput(shirtType s[],ifstream& infile, int& numShirts); int main() { int numShirts; shirtType shirts[500]; ifstream infile; infile.open("h:shirtlab.txt"); getInput(shirts,infile,numShirts); for(int i =0; i>id; infile.ignore(100,' '); getline(infile,c); infile>>size>>p>>q; while(infile) { s[index].setAll(id, c, size, p, q); index++; infile>>id; infile.ignore(100,' '); getline(infile,c); infile>>size>>p>>q; } numShirts=index; } See also the description of the class shirtType below: #include #include using namespace std; class shirtType
  • 2. { private: int shirtID; string color; string size; double price; int quantity; public: void setAll(int i,string c,string s, double p, int q); void print() const; void newQuan(); shirtType(); shirtType(int,string,string,double,int); }; shirtType::shirtType(int i,string c,string s, double p, int q) { color = c; size = s; if(i>0) shirtID=i; else shirtID=0; if(p>0.0) price = p; else price=0.0; if (q>=0) quantity=q; else quantity = 0; } shirtType::shirtType() {
  • 3. shirtID=0; color=""; size=""; price=0.0; quantity=0; } void shirtType::setAll(int i,string c,string s, double p, int q) { color = c; size = s; if(i>0) shirtID=i; else shirtID=0; if(p>0.0) price = p; else price=0.0; if (q>=0) quantity=q; else quantity = 0; } void shirtType::newQuan() { cout<<"Enter the new quantity of shirts: "<>quantity; } void shirtType::print() const { cout<<"Shirt ID: "< Solution #include #include
  • 4. struct node { int data; struct node *next; }*head; void append(int nkkm) { struct node *temp,*right; temp= (struct node *)malloc(sizeof(struct node)); temp->data=nkkm; right=(struct node *)head; while(right->next != NULL) right=right->next; right->next =temp; right=temp; right->next=NULL; } void add( int nkkm ) { struct node *temp; temp=(struct node *)malloc(sizeof(struct node)); temp->data=nkkm; if (head== NULL) { head=temp; head->next=NULL; } else {
  • 5. temp->next=head; head=temp; } } void addafter(int nkkm, int loc) { int i; struct node *temp,*left,*right; right=head; for(i=1;inext; } temp=(struct node *)malloc(sizeof(struct node)); temp->data=nkkm; left->next=temp; left=temp; left->next=right; return; } void addaShirt(int nkkm) { int c=0; struct node *temp; temp=head; if(temp==NULL) { add(nkkm); } else { while(temp!=NULL) { if(temp->datanext; }
  • 6. if(c==0) add(nkkm); else if(cdata==nkkm) { if(temp==head) { head=temp->next; free(temp); return 1; } else { prev->next=temp->next; free(temp); return 1; } } else { prev=temp; temp= temp->next; } } return 0; } void display(struct node *r) { r=head; if(r==NULL) { return; } while(r!=NULL) {
  • 7. printf("%d ",r->data); r=r->next; } printf(" "); } int count() { struct node *n; int c=0; n=head; while(n!=NULL) { n=n->next; c++; } return c; } int main() { int i,nkkm; struct node *n; head=NULL; while(1) { printf("1.Add a shirt "); printf("2.Sell a shirt "); printf("3.Restock a shirt "); printf("4.Print a list of all shirts "); printf("5.Quit "); printf("Enter your choice : "); if(scanf("%d",&i)<=0){
  • 8. printf("Enter only an Integer "); exit(0); } else { switch(i) { case 1: printf("Enter the number to addaShirt : "); scanf("%d",&nkkm); addaShirt(nkkm); break; case 2: if(head==NULL) { printf("List is Empty "); } else { printf("Element(s) in the list are : "); } display(n); break; case 3: printf("Size of the list is %d ",count()); break; case 4: if(head==NULL) printf("List is Empty "); else{ printf("Enter the number to delete : "); scanf("%d",&nkkm); if(delete(nkkm)) printf("%d deleted successfully ",nkkm); else printf("%d not found in the list ",nkkm); } break; case 5: return 0; default: printf("Invalid option "); } }