467,878 Members | 1,264 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,878 developers. It's quick & easy.

FCFS algorithm C++ program please help!

Hi to all,
im just a newbie here..
can someone help me with my program about FCFS scheduling algo,
here the code that i made..
the first 2 process is correct but the succeding process is not.. please help me with the right computation.

note: TAT= Time of completion - Arrival Time;
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. int proc,x,at[10],bt[10],sum;
  5. main()
  6. {
  7. clrscr();
  8.  
  9. printf ("Input number of process: ");
  10. scanf("%d",&proc);
  11.  
  12. printf ("\n\nProcess#\t\tArrival Time\t\tBurst Time\tTat");
  13.  
  14. for (x=1;x<=proc;x++)
  15. {
  16. gotoxy (4,4+x);
  17. printf("%d",x);
  18.  
  19.  
  20. gotoxy (30,4+x);
  21. scanf ("%d", &at[x]);
  22.  
  23. gotoxy (55,4+x);
  24. scanf("%d",&bt[x]);
  25.  
  26. sum=sum+1+bt[x]-at[x];
  27.  
  28. gotoxy (65,4+x);
  29. printf("%d",sum);
  30. }
  31. getch();
  32.  
  33. return 0;
  34. }
  35.  
Thanks a lot!
Feb 10 '08 #1
  • viewed: 12383
Share:
1 Reply
Read Arrival Time and Burst Time for all Process
Let WaitingTime[0] = 0 and TAT[0]=BurstTime[0]
WaitingTime[i]=TAT[i-1]-ArrivalTime[i]
TAT[i]=BurstTime[i]+WaitingTime[i]
Feb 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by abs | last post: by
5 posts views Thread by Nikola | last post: by
9 posts views Thread by kwindham | last post: by
8 posts views Thread by [rob desbois] | last post: by
3 posts views Thread by deepan | last post: by
reply views Thread by jack112 | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.