SlideShare a Scribd company logo
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

PDF
#include iostream #include fstream #include shirtType.h.pdf
PDF
Basic C Programming Lab Practice
PDF
PCA-2 Programming and Solving 2nd Sem.pdf
DOCX
PCA-2 Programming and Solving 2nd Sem.docx
DOCX
Cs pritical file
PDF
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
PDF
Programming Fundamentals Arrays and Strings
DOCX
#include iostream #include fstream #include shirtType.h.pdf
Basic C Programming Lab Practice
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.docx
Cs pritical file
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Programming Fundamentals Arrays and Strings

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

PDF
DSC program.pdf
PPTX
C programming
PDF
Aplikasi menghitung matematika dengan c++
PPTX
C programming codes for the class assignment
PDF
C programms
PDF
C Programming Lab.pdf
DOCX
RAILWAY RESERWATION PROJECT PROGRAM
PDF
C-Program Custom Library, Header File, and Implementation FilesI .pdf
PDF
C faq pdf
TXT
c++ program for Railway reservation
TXT
Railway reservation
PPTX
4. chapter iii
PDF
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
DOCX
Chapter 8 c solution
PDF
Twitter sentiment analysis for cryptoassets
DOCX
12th CBSE Practical File
DOCX
Cd practical file (1) start se
DOCX
SaraPIC
TXT
Railwaynew
DSC program.pdf
C programming
Aplikasi menghitung matematika dengan c++
C programming codes for the class assignment
C programms
C Programming Lab.pdf
RAILWAY RESERWATION PROJECT PROGRAM
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C faq pdf
c++ program for Railway reservation
Railway reservation
4. chapter iii
#include stdio.h#include stdlib.h#include string.h#inclu.pdf
Chapter 8 c solution
Twitter sentiment analysis for cryptoassets
12th CBSE Practical File
Cd practical file (1) start se
SaraPIC
Railwaynew

More from irshadoptical (20)

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

Recently uploaded (20)

PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Complications of Minimal Access Surgery at WLH
PDF
RMMM.pdf make it easy to upload and study
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Lesson notes of climatology university.
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
01-Introduction-to-Information-Management.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Pharmacology of Heart Failure /Pharmacotherapy of CHF
O7-L3 Supply Chain Operations - ICLT Program
Anesthesia in Laparoscopic Surgery in India
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Complications of Minimal Access Surgery at WLH
RMMM.pdf make it easy to upload and study
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
A systematic review of self-coping strategies used by university students to ...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Supply Chain Operations Speaking Notes -ICLT Program
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Lesson notes of climatology university.
Chinmaya Tiranga quiz Grand Finale.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
01-Introduction-to-Information-Management.pdf

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 "); } }