Source Code : Program on Shortest Job

//……..Program on Sjf2.c…….//

# include

#define max 500

main()

{

  int no,i,k=0,l=0,j=0,ax,bx;

  int a[max+1];

  int b[max+1];

//  a[0]=0;

  printf("Enter the number of Processes :");

  scanf("%d",&no);

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

  {

  printf("Enter The prcess  P %d :",i);

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

  b[i]=i;

  printf("\n");

  } 

  for(k=0;k

  {

  for(l=k;l

  {

  if (a[k]>a[l+1])

  { 

  j=a[l+1];

  a[l+1]=a[k];

  a[k]=j;

 

  ax=b[l+1];

    b[l+1]=b[k];

    b[k]=ax;

  }

 

  }

  }

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

  {

  bx=1; 

  for(j=0;j

  {

  printf("\n process %d",b[i],"Is Exicuting ");

  ax=j+1;

  ax=a[i]-ax;

  printf(" is exicuted for %d sec",ax);

  }

  printf("\n\n");

  scanf("%d",bx);

  }

}