Program to implement Placement Algorithm. #include #include #include #include void create() { int i,j,gm,gd; rectangle(100,100,300,450); line(100,150,300,150); for(i=101;i<300;i++) for(j=101;j<150;j++) putpixel(i,j,CYAN); outtextxy(90,100,"O"); outtextxy(200,125,"OS"); line(100,250,300,250); line(100,300,300,300); outtextxy(200,200,"60k"); outtextxy(80,150,"56"); outtextxy(200,275,"40k"); outtextxy(200,350,"100k"); outtextxy(70,250,"116"); outtextxy(70,300,"156"); outtextxy(70,450,"256"); } void fill(int x1,int y1,int x2,int y2) { int i,j; for(i=x1+1;i40 && size<=60) { y=partition(60,100,size); y=y+150; line(100,y,300,y); fill(100,150,300,y); } if(size<=40) { y=partition(40,50,size); y=y+250; line(100,y,300,y); fill(100,250,300,y); } if(size>60 && size<=100) { y=partition(100,150,size); y=y+300; line(100,y,300,y); fill(100,300,300,y); } if(size>100) { outtextxy(50,50,"Process is large"); } } void first(int size) { int y; if(size<=60) { y=partition(60,100,size); y=y+150; line(100,y,300,y); fill(100,150,300,y); } else if(size<=100) { y=partition(100,150,size); y=y+300; line(100,y,300,y); fill(100,300,300,y); } else { outtextxy(50,50,"Process is large"); } } void worst(int size) { int y; if(size<=100) { y=partition(100,150,size); y=y+300; line(100,y,300,y); fill(100,300,300,y); } else { outtextxy(50,50,"Process is large"); } } void main() { int size,gd=DETECT,gm,ch; clrscr(); initgraph(&gd,&gm,"c:\\tc\\bgi"); settextstyle(1,0,1); create(); printf("Enter Size of Process:"); scanf("%d",&size); printf("Enter U R Choice\n1.BEST FIT\n2.FIRST FIT\n3.WORST FIT\n"); scanf("%d",&ch); cleardevice(); create(); switch(ch) { case 1:best(size);break; case 2:first(size);break; case 3:worst(size);break; default: outtextxy(100,100,"Invalid Choice"); } getch(); }