Program to implement FCFS (First Come First Serve ) Algorithm in C | Wave the world

Program to implement FCFS (First Come First Serve ) Algorithm in C

/*
    FCFS (First Come First Serve) Scheduling Algorithm
    Created By: Pirate
*/

#include<stdio.h>
#include<conio.h>
void main(){
    float input[500],process[500],tat[20];
    float avg_wt=0,avg_tat=0;
    int n,i,j;
    printf("*** FCFS Process Scheduling Algorithm ***\n");
    printf("\nEnter number of Processes : ");
    scanf("%d",&n);

    printf("\nEnter Process Burst Time\n");
    for(i=0;i<n;i++){
        printf("P%d : ",i+1);
        scanf("%f",&input[i]);
    }

    process[0]=0;

    for(i=1;i<n;i++){
        process[i]=0;
        for(j=0;j<i;j++)
            process[i]+=input[j];
    }
    printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time");

    for(i=0;i<n;i++){
        tat[i]=input[i]+process[i];
        avg_wt+=process[i];
        avg_tat+=tat[i];
        printf("\nP[%d]\t\t%.2f\t\t%.2f\t\t%.2f",i+1,input[i],process[i],tat[i]);
    }

    avg_wt/=i;
    avg_tat/=i;
    printf("\n\nAverage Waiting Time     :  %.2f",avg_wt);
    printf("\nAverage Turnaround Time  :  %.2f\n",avg_tat);

}

Output



4 comments:

  1. what is that process returned?

    ReplyDelete
  2. it is not correct because you did not consider arrival time and assume all the process come at the same time.

    ReplyDelete
    Replies
    1. I assume that all the process come at the same time. I'll post another post for FCFS with arrival time also.

      Delete

 

Pro

About