



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Task 1 Create a program to store a record using structure. You need to define one structure template with minimum 3 data members. In main function, declare five structure variables, then get input from user and store into the variable. Then your program will display the content of the structure on the screen output. Program Description Explain about your developed program Coding Paste your program here #include
Task 2 Use the structure definition in Task 1 to store 5 records using an array of structure with five elements. Get the data from user, store into the array, then display the output in table format. Program Description Explain about your developed program Coding Paste your program here #include
n"; cout<<"---------------------------------------------------------------\n"; for(index=0; index<5; index++) { cout<<setw(30)<<left<<Record[index].lipstick;
cout<<setw(15)<<left<<Record[index].price; cout<<setw(5)<<left<<Record[index].noofpage; } } Sample output
cin.getline(Record[index].lipname,30); cout<<"Enter Lipstick Shade: "; cin>>ws; cin.getline(Record[index].shade,30); cout<<"Enter Lipstick Finishing: "; cin>>ws; cin.getline(Record[index].finish,30); cout<<"Enter lipstick price (RM): "; cin>>Record[index].price; cout<<"Enter the shop name: "; cin>>ws; cin.getline(Record[index].lipstickshop.name,30); cout<<"Enter shop's email: "; cin>>ws; cin>>Record[index].lipstickshop.email; cout<<"Enter shop contact number: "; cin>>Record[index].lipstickshop.contactNo; cout<<endl; } cout<<"\n\nList of lipstick \n"; cout<<"---------------------------------------------------------------\n"; cout<<setw(30)<<left<<"bodyshop"<<setw(15)<<left<<"Price(RM)"<<setw(5)<<left<<"No Of lipstick\n"; cout<<"---------------------------------------------------------------\n"; for(index=0; index<5; index++) { cout<<setw(30)<<left<<Record[index].brand; cout<<setw(15)<<left<<Record[index].lipname; cout<<setw(5)<<left<<Record[index].shade; cout<<setw(5)<<left<<Record[index].finish; cout<<setw(5)<<left<<Record[index].price; cout<<setw(30)<<left<<Record[index].lipstickshop.name; cout<<setw(20)<<left<<Record[index].lipstickshop.email; cout<<left<<Record[index].lipstickshop.contactNo<<endl; } } Sample output