fix this c code and only fix syntax error and logical errors and make it runnable:…
- User
fix this c code and only fix syntax error and logical errors and make it runnable:
#include<stdio.h> int main(){ int i, limit, total = 0, x, counter = 0, time_quantum,tbm; int wait_time = 0, turnaround_time = 0, arrival_time[10], burst_time[10], temp[10]; float average_wait_time, average_turnaround_time; printf("\nEnter Total Number of Processes:\t"); scanf("%d", &limit); x = limit; for(i=0; i < limit; i++) { printf("\nEnter Details of Process[%d]\n", i + 1); printf("Arrival Time:\t"); scanf("%d", &arrival_time[i]); printf("Burst Time:\t"); scanf("%d", &burst_time[i]); temp[i] = burst_time[i]; } printf("\nEnter Time Quantum:\t"); scanf("%d", &time_quantum); printf("\nProcess ID\t\tBurst Time\t Turnaround Time\t WaitingTime\n"); for(total = 0, i = 0; x != 0;) { if(temp[i] <= time_quantum && temp[i] > 0) { total = total + temp[i]; temp[i] = 0; counter = 1; } else if(temp[i] > 0) { printf(" process %d: \n", i+1); scanf("%d%d",&p[i].btime,&p[i].pri); p[i].pno=i+1; p[i].wtime=0; } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++)
{ if(p[i].pri>p[j].pri) { t=p[i]; p[i]=p[j]; p[j]=t; } } printf("\n process\tbursttime\twaiting time\tturnaround time\n"); for(i=0;i<n;i++) { totwtime+=p[i].wtime=tbm; tbm+=p[i].btime; printf("\n\t%d\t\t\t%d",p[i].pno,p[i].btime); printf("\t\t\t%d\t\t\t%d",p[i].wtime,p[i].wtime+p[i].btime); } totttime-tbm+totwtime; printf("\n Total waiting time:%d",totwtime); printf("\n Average waiting time:%f", (float)totwtime/n); printf("\n Total turnaround time:%d",totttime); printf("\n Avg turnaround time:%f", (float)totttime/n); return 0; }
- Assistant