write a program in c++ which makes use of the structure and nested structure to implement an online shopping store for clothes. Get product details from user and store in arrar( size=5) of structure. Ask user to press 'Y' or'y' to continue. Keep taking input from user until user presses any character other than 'Y' or limit (size of array) reaches. following must be stored. product Id , Product Name , price, color, product catogery
#include<iostream>
using namespace std;
struct others{
char color[10];
char category[10];
};
struct onlinestore{
int productid;
char productname[10];
double price;
struct others Add;
};
int main(){
int i=1,g;
char y='Y';
onlinestore item[100];
while((y=='y') || (y=='Y')){
cout<<"Enter product id"<<endl;
cin>>item[i].productid;
cout<<"Enter product name"<<endl;
cin>>item[i].productname;
cout<<"Enter product price"<<endl;
cin>>item[i].price;
cout<<"Enter product color"<<endl;
cin>>item[i].Add.color;
cout<<"Enter product category"<<endl;
cin>>item[i].Add.category
;
cout<<"Enter Y(or y) to continue and any other letter to stop"<<endl;
cin>>y;
g=i;
i++;
}
for(int k=1;k<=g;k++){
cout<<k<<"\tproduct id="<<item[k].productid<<endl;
cout<<k<<"\tproduct name="<<item[k].productname<<endl;
cout<<k<<"\tproduct price="<<item[k].price<<endl;
cout<<k<<"\tproduct color="<<item[k].Add.color<<endl;
cout<<k<<"\tproduct category="<<item[k].Add.category<<endl;
}
return 0;}
Comments
Leave a comment