Source Code : Program on Shortest Job1

//………….Program on Sjf.c…………//

#include

#include

main()

{

  int i,j,k,l,m,n,h,bt[10],pid[10],t[10];

 

  printf("\n How many processes u want to enter:");

  scanf("%d",&n);

  for(i=0;i

  {

  printf("\n Enter the processes.....");

  scanf("%d",&bt[i]);

  printf("\n Enter the burst time....");

  scanf("%d",&t[i]);

  }

  for(j=0;j

  {

  for(k=0;k

  {

  if(bt[j]>bt[k+1])

  {

  l=bt[k+1];

  bt[k+1]=bt[j];

  bt[j]=l;

  m=pid[k+1];

  pid[k+1]=pid[j];

  pid[j]=m;

  }

  }

  }

  for(i=1;i<=n;i++)

  {

  printf("\nProcess id : %d",pid[i]);

  printf("\n burst time : %d",bt[i]);

  }

  printf("\n");

  for(i=1;i<=n;i++)

  {

  printf("\nPress 1 to execute");

  scanf("%d",&h);

  if(h==1)

  {

  printf("\nprcess %d start to executing.....",pid[i]);

  for(j=1;j<=bt[i];j++)

  {

  printf("\n P %d is exicuted for",pid[j]);

  printf("\t%d sec",bt[i]-j);

  }

  printf("\n process %d is executed",pid[i]);

  }

  else

  {

  exit(0);

  }

  }

}