ash_wath

Fcfs

Sep 4th, 2017
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include<stdio.h>
  2. main()
  3. {
  4. int n,a[10],b[10],t[10],w[10],g[10],i,m;
  5. float att=0,awt=0;
  6. for(i=0;i<10;i++)
  7. {
  8. a[i]=0; b[i]=0; w[i]=0; g[i]=0;
  9. }
  10. printf("enter the number of process");
  11. scanf("%d",&n);
  12. printf("enter the burst times");
  13. for(i=0;i<n;i++)
  14. scanf("%d",&b[i]);
  15. printf("\nenter the arrival times");
  16. for(i=0;i<n;i++)
  17. scanf("%d",&a[i]);
  18. g[0]=0;
  19. for(i=0;i<10;i++)
  20. g[i+1]=g[i]+b[i];
  21. for(i=0;i<n;i++)
  22. {
  23. w[i]=g[i]-a[i];
  24. t[i]=g[i+1]-a[i];
  25. awt=awt+w[i];
  26. att=att+t[i];
  27. }
  28. awt =awt/n;
  29. att=att/n;
  30. printf("\n\tprocess\twaiting time\tturn arround time\n");
  31. for(i=0;i<n;i++)
  32. {
  33. printf("\tp%d\t\t%d\t\t%d\n",i,w[i],t[i]);
  34. }
  35. printf("the average waiting time is %f\n",awt);
  36. printf("the average turn around time is %f\n",att);
  37. }
Add Comment
Please, Sign In to add comment