al__nasim

fcfs.cpp

Jan 14th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,p,b[100], w=0,t;
  7. float awt =0,att=0, aw=0, at=0;
  8.  
  9. printf("Enter the process no : ");
  10. scanf("%d",&n);
  11.  
  12. for(int i=0; i<n; i++)
  13. {
  14. printf("Enter the burst time for process %d : ",i+1);
  15. scanf("%d",&b[i]);
  16. }
  17.  
  18. printf("Process \t bt \t wt \t tt");
  19.  
  20. for(int i=0; i<n; i++)
  21. {
  22. t = w+b[i];
  23. printf("\n %d \t\t %d \t %d \t %d", i+1,b[i],w,t);
  24. at = at + t;
  25. aw = aw+w;
  26. w = w+b[i];
  27.  
  28. }
  29. att = at/n;
  30. awt = aw/n;
  31.  
  32. printf("\n Average waiting time: %f and average turnedaround time: %f",awt,att);
  33.  
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment