Professional Documents
Culture Documents
Scenario Problem: Manaswi 20BPS1019
Scenario Problem: Manaswi 20BPS1019
Manaswi
20BPS1019
Question
1. Assume that a set of N number of medicines are arrived on a pharmacy store. There
are three category of rack in the pharmacy for three category of medicine such as
tablets, liquids and pastes. Every medicine is associated with a name, price and the
category.
Implement a program to get the N number of medicines to be kept in the rack(requires one
data structure). According to the category arrange the medicines in the respective three
rack’s (requires three data structure). Display the medicines in the racks and the sum of the
price of all the medicines. (Use either stack or queue data structure)
Algorithm
Start
Create a stack to hold the information about the medicined
Get input from user which includes: name, category, price
Store this information in stack
Create 3 stacks to store the medicine in different rack depending in the category i.e. tablets,
liquids or pastes
end
CODE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 50
top=top+1;
strcpy(m[top], total);
void pop()
top=top-1;
if(top==-1){
printf("%s EMPTY\n",r);
else{
printf("%s\n", m[i]);
}
}
int main()
char n[50],c[50],pr[50];
scanf("%d",&a);
char q1[]="tablet";
char q2[]="liquid";
char q3[]="paste";
for(int i=0;i<a;i++)
scanf("%s", n);
push(n);
scanf("%s", c);
push(c);
scanf("%s", pr);
push(pr);
for(int i=top;i>=0;i=i-3)
strcpy(n,m[i]);
strcpy(pr,m[i-1]);
strcpy(c,m[i-2]);
s=s+cost;
if (strcmp(c,q1)==0){
top1=top1+1;
strcpy(t[top1],n);
s1=s1+ cost;
pop();
pop();
pop();
else if(strcmp(c,q2)==0){
top2=top2+1;
strcpy(l[top2],n);
s2=s2+ cost;
pop();
pop();
pop();
else if(strcmp(c,q3)==0){
top3=top3+1;
strcpy(p[top3],n);
s3=s3+cost;
pop();
pop();
pop();
dis(top1,q1,t);
dis(top2,q2,l);
dis(top3,q3,p);
OUTPUT