Question: Can anyone tell me whats wrong with my code? I'm getting the error : expected declaration or statement at end of input #include #include struct

Can anyone tell me whats wrong with my code? I'm getting the "error : expected declaration or statement at end of input"

#include #include

struct ItemsDetails //hold items details ofeach location

{

int top;

int quantity[100000];

int cost[100000];

char Items[100000][19];

};

void PreProcess( struct ItemsDetails locations[],int n)

{

int index=0;

for(index=0;index

locations[index].top=-1;

}

int main() {

struct ItemsDetails locations[1001];//size is 1001 because the size of k is maximum 1000

PreProcess(locations,1001);//intializing the each locations to stac value -1

while(1)

{

int type;

scanf("%d",&type);

if(type==0)

break;

if(type==1)

{

int Loc,bags,index=0;

scanf("%d%d",&Loc,&bags);

for(index=0;index

{

int m,w;

locations[Loc].top++;

scanf("%d %d %s",&m,&w,locations[Loc].Items[locations[Loc].top]);

locations[Loc].cost[locations[Loc].top]=m;

locations[Loc].quantity[locations[Loc].top]=w;

}

}

if(type==-1)

{

int totalSold=0;

char temp[19];

char Items[100000][19];

int soldItem=0;

int k,m,c;

scanf("%d%d%d",&k,&m,&c);

if(locations[k].top==-1 || locations[k].cost[locations[k].top]>m || locations[k].quantity[locations[k].top]>c)

printf(" 0");

else

{

while(locations[k].top!=-1 && locations[k].cost[locations[k].top]<=m && locations[k].quantity[locations[k].top]<=c)

{

totalSold+=locations[k].cost[locations[k].top];

strcpy(Items[soldItem],locations[k].Items[locations[k].top]);

m=m-locations[k].cost[locations[k].top];

c=c-locations[k].quantity[locations[k].top];

locations[k].top--;

soldItem++;

}

printf("%d ",totalSold);

while(soldItem>=0)

{

printf("%s ",Items[soldItem]);

soldItem--;

}

printf(" ");

}

}

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!