Wednesday, March 9, 2016

First Come First Serve(Operating System)

//Created by "Arunendra Kumar"//
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,sum=0,total;
float avg;
clrscr();
printf("\nEnter the no of process : ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the burst time for the prcess %d is :",i);
scanf("%d",&a[i]);
}
printf("\nProcess\t\tBurst time\n");
for(i=1;i<=n;i++)
{
printf("%d\t\t%d\n",i,sum);
sum=sum+a[i];

}
sum=0;
total=0;
for(i=1;i<n;i++)
{
sum=sum+a[i];
total=total+sum;
}
avg=total/(float)n;
printf("\nTotal burst time taken by process : %d microseconds",total);
printf("\nAvarage time taken by processes : %f microseconds",avg);
getch();
}

No comments:

Post a Comment