Monday, 20 October 2014

c code for first come first serve scheduling algorithm.

#include<stdio.h>

void display();
void getdata();
void waittiome();
int n,b[100];
int main()
{
    printf("-----Fcfs algorithm----\n\n");
    getdata();
    display();
    waittime();
    getch();
}
void getdata()
{
    printf("enter no. of pocesses");
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        printf("enter the %d processes burst time time ",i);
        scanf("%d",&b[i]);
    }
}
void waittime()
{
    int w[100];
    float totalwait=0;
    w[0]=0;
    for(int i=1;i<n;i++)
    {
        w[i]=b[i-1]+w[i-1];
        totalwait=w[i]+totalwait;
    }
    printf("toal wait time =%d",totalwait);
    printf("total average wait time= %d",totaltime/n);
    
}

No comments:

Post a Comment