FCFS algorithm C++ program please help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • naomisan
    New Member
    • Feb 2008
    • 1

    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;
    [code=c]
    #include<stdio. h>
    #include<conio. h>

    int proc,x,at[10],bt[10],sum;
    main()
    {
    clrscr();

    printf ("Input number of process: ");
    scanf("%d",&pro c);

    printf ("\n\nProcess#\ t\tArrival Time\t\tBurst Time\tTat");

    for (x=1;x<=proc;x+ +)
    {
    gotoxy (4,4+x);
    printf("%d",x);


    gotoxy (30,4+x);
    scanf ("%d", &at[x]);

    gotoxy (55,4+x);
    scanf("%d",&bt[x]);

    sum=sum+1+bt[x]-at[x];

    gotoxy (65,4+x);
    printf("%d",sum );
    }
    getch();

    return 0;
    }
    [/code]
    Thanks a lot!
    Last edited by sicarie; Feb 10 '08, 01:52 PM. Reason: Code tags
  • Ariharan
    New Member
    • Aug 2007
    • 20

    #2
    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]

    Comment

    Working...