Question: this is the round robin algorithm implemented using C++ in need each line in this code to be explained please #include using namespace std; int

this is the round robin algorithm implemented using C++ in need each line in this code to be explained please

#include

using namespace std;

int main(){ int i,j,k=0,p=0,q,temp,s=0,idle=0,done=0; float sum=0; cout<<"Please enter the number of proces : "; cin>>p; int a[p][4]; int b[p][5]; cout<<"Please enter the Time Quantum : "; cin>>q; cout<<" Process\tArrival\tBurst -------\t-------\t----- "; for(i=0;i>a[i][j]; } a[i][3]=a[i][2]; } cout<<" Time-Line is as follows (Verticle View).... "; i=a[0][1]; while(done!=p){ if(k==p) k=0; if(a[k][1]<=i){ if(a[k][2]!=0){ if(a[k][2]>=q){ printf("%5d----------- |p-%-4d| ",i,a[k][0]); a[k][2]-=q; i+=q; } else{ printf("%5d----------- |p-%-4d| ",i,a[k][0]); i+=a[k][2]; a[k][2]=0; } if(a[k][2]==0){ b[s][0]=a[k][0]; b[s][1]=a[k][1]; b[s][2]=i; b[s][3]=a[k][3]; b[s][4]=((i-a[k][1])-a[k][3]); sum+=((i-a[k][1])-a[k][3]); s++; done++; } idle=0; } k++; } else{ if(idle==0){ idle=1; k=0; } else if(idle==1){ printf("%5d----------- |Idle| ",i); idle=2; i++; } else i++; } } printf("%5d-----------\t",i); cout<

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!