Search
 
SCRIPT & CODE EXAMPLE
 

C

FCFS algorithm in c to find average turnaround time and waiting time


#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 Timen");
    for(i=0;i<n;i++)
    {
        printf("P[%d]:",i+1);
        scanf("%d",&bt[i]);
    }
 
    wt[0]=0;   
 
    for(i=1;i<n;i++)
    {
        wt[i]=0;
        for(j=0;j<i;j++)
            wt[i]+=bt[j];
    }
 
    printf("nProcessttBurst TimetWaiting TimetTurnaround Time");
 
    for(i=0;i<n;i++)
    {
        tat[i]=bt[i]+wt[i];
        avwt+=wt[i];
        avtat+=tat[i];
        printf("nP[%d]tt%dtt%dtt%d",i+1,bt[i],wt[i],tat[i]);
    }
 
    avwt/=i;
    avtat/=i;
    printf("nnAverage Waiting Time:%d",avwt);
    printf("nAverage Turnaround Time:%d",avtat);
 
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: sockaddr_in c 
C :: how to sort an int array in c 
C :: c program to implement mv command 
C :: C program to input the month number and output the month name using switch statement 
C :: how to change file permissions in C language 
C :: Turn on the first n Bits in number 
C :: why do you jerk while falling aslee 
C :: fahrenheit to celcius 
C :: refresh a chromebook terminal 
C :: how to check the word is present in given char array in c 
C :: binary sorting 
C :: how to open form in vb.net 
C :: Multi-line Comments in C 
C :: c defined value sum 
C :: declare an array 
C :: what is O(N^2) in bubble sort method 
C :: C/AL Convertion of Decimal to String/Text 
C :: how to check file pointers in c 
C :: how to belu-roll peoples in c 
C :: ansi c write unsigned short to file 
C :: bool print variable in c 
C :: execute asm in c 
C :: arma 3 key pressed 
C :: djb2 algorithm for C 
C :: when to add & in snacf c 
C :: function that reverses the content of an array of integers. 
C :: changing data type in one line c program 
C :: openinh VCL file for Vivado HLS 
C :: inline function in c example 
C :: c programming trinary if 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =