Hanochsunil / lab

0 stars 0 forks source link

FIRST #9

Open Hanochsunil opened 2 months ago

Hanochsunil commented 2 months ago

include

struct pro{ int size,allocated; }pro[20]; void main() { int i,j,np,nb,block[10]; printf("Enter the no of process"); scanf("%d",&np); printf("Enter the process block"); for(i=0;i<np;i++) { scanf("%d",&pro[i].size); pro[i].allocated=-1; } printf("Enter the no of memory locations"); scanf("%d",&nb); printf("Enter the size locations"); for(i=0;i<nb;i++) { scanf("%d",&block[i]); } for(i=0;i<np;i++) { for(j=0;j<nb;j++) { if(block[j]>=pro[i].size) { pro[i].allocated=block[j]; block[j]=block[j]-pro[i].size; break; } } } printf("Si.no process allocation\n"); for(i=0;i<np;i++) { if(pro[i].allocated!=-1) { printf("%d\t%d\t%d\n",i+1,pro[i].size,pro[i].allocated); } else { printf("%d\t%d\tnot allocated\n",i+1,pro[i].size); } } }