first come first served scheduling non-preemptive| C code

#include<conio.h> #include<stdio.h> void main() { int n,B_T[1000],W_T=0,T_A_T=0; int i,j,line[10],line1[10]; system("Title CPU Scheduling FCFS-Non preemptive "); float AVR_TAT=0,AVR_W_T=0; printf("Enter Number of Processes : "); scanf("%d",&n); printf("\n"); for (i=0; i<n; i++) { printf("Enter Burst time for P%d : ",i); scanf("%d",&B_T[i]); } printf("\n\nProcess Name \t Burst Time \t Waiting Time \t Turn Around Time"); for(i=0; i<n; i++) { T_A_T = B_T[i] + W_T; AVR_W_T+=W_T; printf("\nP%d\t\t %d\t\t %d\t\t %d",i,B_T[i],W_T,T_A_T); line1[i]=W_T; W_T +=B_T[i]; AVR_TAT+=T_A_T; line[i]=T_A_T; } printf("\n"); printf("\nAverage Turn Around Time = %.2f \n",AVR_TAT/n); printf("Average Waiting Time = %.2f \n",AVR_W_T/n); printf("\n"); for(i=0;i<AVR_TAT/2;i++) { printf(" "); } printf("GANTT CHART\n\n"); for(i=0;i<n;i++) { for(j=0;j<(line1[i]+line[i])/2;j++) { printf(" "); } printf("P%d",i); } printf("\n"); printf("0"); for(i=0;i<n; i++) { for(j=0;j<line[i];j++) { printf("-"); } printf("%d",line[i]); } printf("\n"); getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.