-
Notifications
You must be signed in to change notification settings - Fork 0
/
file1.c
67 lines (61 loc) · 1.94 KB
/
file1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
struct student
{
int StudentId;
int FoodTakenTime;
int WaitingTime;
int TurnAroundTime;
};
void accept(struct student list[], int s);
void display(struct student list[], int s);
void scheduling(struct student list[], int s);
void waitingTime(struct student list[], int n);
void turnAroundTime(struct student list[], int n);
int main()
{
struct student data[20];
int n,i;
char c='n';
do
{
printf("Please enter the No. of Students wants to eat in mess? : ");
scanf("%d", &n);
accept(data, n);
scheduling(data, n);
waitingTime(data,n);
turnAroundTime(data,n);
display(data, n);
printf("Want to continue? press 'y' : ");
scanf("%s",&c);
}while(c=='y');
return 0;
}
void accept(struct student list[80], int s)
{
int i;
for (i = 0; i < s; i++)
{
printf("\n\nEnter data for Student #%d", i + 1);
printf("\nEnter Student id : ");
scanf("%d", &list[i].StudentId);
printf("Enter time taken for food (minuts): ");
scanf("%d", &list[i].FoodTakenTime);
}
}
void display(struct student list[80], int s)
{
int i,AvgWaitingTime=0,AvgTurnAroundTime=0;
int TotalWatingTime=0,TotalTurnAroundTime=0;
printf("\n\n\t\t\tOutput according to LRTF\n");
printf("\n\t\t\t|Student id\tFoodTakenTime\tWaitingTime\tTurnAroundTime |");
for (i = 0; i < s; i++)
{
printf("\n\t\t\t|%d\t\t%d\t\t%d\t\t%d\t\t|", list[i].StudentId, list[i].FoodTakenTime,list[i].WaitingTime,list[i].TurnAroundTime);
TotalWatingTime= TotalWatingTime+list[i].WaitingTime;
TotalTurnAroundTime= TotalTurnAroundTime+list[i].TurnAroundTime;
}
printf("\n\n\t\t\tTotal Waiting Time is: = %d",TotalWatingTime);
printf("\n\t\t\tTotal Turn around Time is: = %d\n\n",TotalTurnAroundTime);
printf("\n\n\t\t\tAverage Waiting Time is: = %d",TotalWatingTime/s);
printf("\n\t\t\tAverage Turn around Time is: = %d\n\n",TotalTurnAroundTime/s);
}