Professional Documents
Culture Documents
Practical 4 (1)
Practical 4 (1)
Practical 4 (1)
int temp2=P[j];
P[j]=P[i];
P[i]=temp2;
}
}
}
WT[0]=0;
for(i=1;i<n;i++)
{
WT[i]=WT[i-1]+BT[i-1];
totalW=totalW+WT[i];
}
avgWT=float(totalW/n);
cout<<"\nProcesses \t Burst_Time \t Waiting_Time \n";
for(i=0;i<n;i++)
{
cout<<P[i]<<"\t\t"<<BT[i]<<"\t\t"<<WT[i]<<endl;
}
cout<<"\nTotal Wating time = "<<totalW;
cout<<"\nAverage waiting time = "<<avgWT<<endl;
return 0;
}
Output :
Enter how many processes you want to enter : 4
Enter the processes :
1
2
3
4