provive the linux c output screenshot for the code below: #include int main(){ int n, at[10], bt[10], wt[10], ct[10], p[100], t=0, temp, small,k; float att=0.0, awt=0.0 ; printf("enter no.of processes: "); scanf("%d",&n); for(int i=0;iat[j]){ temp=at[i]; at[i]=at[j]; at[j]=temp; temp=bt[i]; bt[i]=bt[j]; bt[j]=temp; } } } for(int i=0;i %d turnaround time==>%d waiting time==>%d\n", i+1,ct[i]+1,(ct[i]-at[i])+1, (((ct[i]+1)-wt[i])-at[i])); awt=awt+(((ct[i]+1)-wt[i])-at[i]); att=att+((ct[i]-at[i]+1); } printf("\n awt==>\t%f\n att==>\t%f\n", (awt/n),(att/n)); return 0; }
provive the linux c output screenshot for the code below:
#include<stdio.h>
int main(){
int n, at[10], bt[10], wt[10], ct[10], p[100], t=0, temp, small,k;
float att=0.0, awt=0.0 ;
printf("enter no.of processes: ");
scanf("%d",&n);
for(int i=0;i<n;i++){
printf("enter arrival time of process %d:\t",i);
scanf("%d",&bt[i]);
wt[i]=0;
t+=bt[i];
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(at[i]>at[j]){
temp=at[i];
at[i]=at[j];
at[j]=temp;
temp=bt[i];
bt[i]=bt[j];
bt[j]=temp;
}
}
}
for(int i=0;i<t;i++){
small=25000;
for(int j=0;j<n;j++)
{
if((bt[j] != 0) && (at[j]<=i) && (bt[j]<small))
{
small=bt[j];
k=j;
}
}
bt[k]--;
p[i]=k;
}
k=0;
for(int i=0;i<total;i++){
for(j=0;j<n;j++)
{
if(p[i]==j)
{
ct[j]=i;
wt[j]++;
}
}
}
for(int i=0;i<n;i++){
printf("\n process %d:-finish time==> %d turnaround time==>%d waiting time==>%d\n", i+1,ct[i]+1,(ct[i]-at[i])+1, (((ct[i]+1)-wt[i])-at[i]));
awt=awt+(((ct[i]+1)-wt[i])-at[i]);
att=att+((ct[i]-at[i]+1);
}
printf("\n awt==>\t%f\n att==>\t%f\n", (awt/n),(att/n));
return 0;
}
Introduction:
Given Code have some basic errors after resolving those error.
Correct Source Code and Output Screenshot is shown other Steps-
Step by step
Solved in 3 steps with 1 images