Search
 
SCRIPT & CODE EXAMPLE
 

C

c sjf


#include<stdio.h>
 int main()
{
    int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;
    float avg_wt,avg_tat;
    printf("Enter number of process:");
    scanf("%d",&n);
  
    printf("nEnter Burst Time:n");
    for(i=0;i<n;i++)
    {
        printf("p%d:",i+1);
        scanf("%d",&bt[i]);
        p[i]=i+1;         
    }
  
   //sorting of burst times
    for(i=0;i<n;i++)
    {
        pos=i;
        for(j=i+1;j<n;j++)
        {
            if(bt[j]<bt[pos])
                pos=j;
        }
  
        temp=bt[i];
        bt[i]=bt[pos];
        bt[pos]=temp;
  
        temp=p[i];
        p[i]=p[pos];
        p[pos]=temp;
    }
   
    wt[0]=0;            
  
   
    for(i=1;i<n;i++)
    {
        wt[i]=0;
        for(j=0;j<i;j++)
            wt[i]+=bt[j];
  
        total+=wt[i];
    }
  
    avg_wt=(float)total/n;      
    total=0;
  
    printf("nProcesst    Burst Time    tWaiting TimetTurnaround Time");
    for(i=0;i<n;i++)
    {
        tat[i]=bt[i]+wt[i];   
        total+=tat[i];
        printf("np%dtt  %dtt    %dttt%d",p[i],bt[i],wt[i],tat[i]);
    }
  
    avg_tat=(float)total/n;    
    printf("nnAverage Waiting Time=%f",avg_wt);
    printf("nAverage Turnaround Time=%fn",avg_tat);
}
Comment

PREVIOUS NEXT
Code Example
C :: len of str vbs 
C :: c for result 
C :: gandhi ashram saharanpur 
C :: swap using third variable 
C :: recursion function bangla 
C :: entity framework core discard changes 
C :: program in c to print 1 to 100 without using loop 
C :: how to change the smartart style to 3D polished in powerpoint 
C :: How can you invoke the constructor from the parent class? *ruby 
C :: how can i learn c game development 
C :: What does x = (a<b)? A:b mean in C programming? 
C :: how to link flexslider 
C :: konami code hdl 
C :: code_art_bcm_10.c 
C :: Here is a program in C that illustrates the use of fscanf() to read a text file: 
C :: Handling exceptions during datetime conversion 
C :: Uri/beecrowd problem no - 1099 solution in C 
C :: gnuplot rectangle border color 
C :: networkx remove attributes 
C :: Sum of upper & lower triangles elements 
C :: how to add a number before every line in c language 
C :: Manage Menu Driven Program using switch statement 
C :: function declaration in c 
C :: not repeated serial number in c 
C :: print binary c 
C :: website how to solve c programming questions 
Dart :: flutter remove debug flag 
Dart :: flutter clear navigation stack 
Dart :: Keyboard Pushes Text Fields off screen flutter 
Dart :: remove space from string dart 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =