Practical 1
Practical 1
SJF:
#include<stdio.h>
int main() {
int p[20], bt[20], wt[20], tat[20], n, i, j, temp;
float wtavg = 0, tatavg = 0;
printf("Onkar lonsane Roll no = 28");
// Input burst times for each process and initialize process numbers
printf("\nEnter Burst Time for each process:\n");
for(i = 0; i < n; i++) {
p[i] = i + 1; // Process numbers from 1 to n
printf("P%d: ", p[i]);
scanf("%d", &bt[i]);
}
// Display results
printf("\nProcess\tBurst Time\tWaiting Time\tTurnaround Time\n");
for(i = 0; i < n; i++) {
printf("P%d\t%d\t\t%d\t\t%d\n", p[i], bt[i], wt[i], tat[i]);
}
printf("\nAverage Waiting Time: %.2f", wtavg);
printf("\nAverage Turnaround Time: %.2f\n", tatavg);
return 0;
}
Output:
/tmp/q8EEUuwxue.o
Onkar lonsane Roll no = 28
Enter the number of processes: 3