FCFS(First Come First Serve) Program in C

 FCFS stand for First Come First Served. In this program you will learn how to work FCFS program in c. First in, first out (FIFO), is also known as first come, first served (FCFS), it is the simplest scheduling algorithm. FIFO is the simply queues processes in the order that they arrive in the ready queue.


FCFS Program:


#include<stdio.h>

int main()
{
    int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;
    printf("Enter total number of processes(maximum 20):");
    scanf("%d",&n);

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

    wt[0]=0;    //waiting time for first process is 0

    //calculating waiting time
    for(i=1;i<n;i++)
    {
        wt[i]=0;
        for(j=0;j<i;j++)
            wt[i]+=bt[j];
    }

    printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time");

    //calculating turnaround time
    for(i=0;i<n;i++)
    {
        tat[i]=bt[i]+wt[i];
        avwt+=wt[i];
        avtat+=tat[i];
        printf("\nP[%d]\t\t%d\t\t%d\t\t%d",i+1,bt[i],wt[i],tat[i]);
    }

    avwt/=i;
    avtat/=i;
    printf("\n\nAverage Waiting Time:%d",avwt);
    printf("\nAverage Turnaround Time:%d",avtat);

    return 0;
}




Output:- 

FCFS Program

Post a Comment

1 Comments

  1. Companies similar to 로스트아크 GeoComply, which relies in Vancouver, British Columbia, say they make use of dozens of engineers to keep up with new spoofing software program. New Jersey, which had led the nation phrases of|when it comes to|by method of} the quantity of sports activities bets its casinos and horse tracks took, had its finest month in October 2021, when it took $1.three billion in bets. New Jersey’s figures for January 2022 shall be launched Feb. 16. "Because they're late coming to the table of sports activities gambling, perhaps they suppose they're gonna certainly make it more interesting for the operators to return here if it is a lower tax fee," McGowan said.

    ReplyDelete