Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- More
- 1 of 73
- Fwd: week 1
- Inbox
- x
- guna srujith reddy
- Attachments2:09 PM (8 minutes ago)
- to me
- ---------- Forwarded message ----------
- From: guna srujith reddy <gunasrujithreddy53@gmail.com>
- Date: Wed, Jul 25, 2018 at 1:25 PM
- Subject: Fwd: week 1
- To: saikumarmalapathi35@gmail.com, malkapuramvamshi@gmail.com
- ---------- Forwarded message ----------
- From: Aashritha Aash <aashritha123aash@gmail.com>
- Date: Wed, Jul 25, 2018 at 1:11 PM
- Subject: Fwd: week 1
- To: gunasrujithreddy53@gmail.com
- ---------- Forwarded message ----------
- From: Sayona Sebastian <sayonamaria@gmail.com>
- Date: Wed, Jul 18, 2018 at 3:45 PM
- Subject: week 1
- To: Harshini venteru <harshiniv216@gmail.com>, namarishika@gmail.com, srathiba chowdary <srathibachowdary@gmail.com>, potlapally kundhana rao <potlapally.kundhanarao@gmail.com>, Aashritha Aash <aashritha123aash@gmail.com>
- 4 Attachments
- Click here to Reply or Forward
- 0.14 GB (0%) of 15 GB used
- Manage
- Terms · Privacy · Program Policies
- Last account activity: 22 hours ago
- Details
- #include<stdio.h>
- int main()
- {
- int count,j,n,time,remain,flag=0,time_quantum;
- int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10];
- printf("Enter Total Process:\t ");
- scanf("%d",&n);
- remain=n;
- for(count=0;count<n;count++)
- {
- printf("Enter Arrival Time and Burst Time for Process Process Number %d :",count+1);
- scanf("%d",&at[count]);
- scanf("%d",&bt[count]);
- rt[count]=bt[count];
- }
- printf("Enter Time Quantum:\t");
- scanf("%d",&time_quantum);
- printf("\n\nProcess\t|Turnaround Time|Waiting Time\n\n");
- for(time=0,count=0;remain!=0;)
- {
- if(rt[count]<=time_quantum && rt[count]>0)
- {
- time+=rt[count];
- rt[count]=0;
- flag=1;
- }
- else if(rt[count]>0)
- {
- rt[count]-=time_quantum;
- time+=time_quantum;
- }
- if(rt[count]==0 && flag==1)
- {
- remain--;
- printf("P[%d]\t|\t%d\t|\t%d\n",count+1,time-at[count],time-at[count]-bt[count]);
- wait_time+=time-at[count]-bt[count];
- turnaround_time+=time-at[count];
- flag=0;
- }
- if(count==n-1)
- count=0;
- else if(at[count+1]<=time)
- count++;
- else
- count=0;
- }
- printf("\nAverage Waiting Time= %f\n",wait_time*1.0/n);
- printf("Avg Turnaround Time = %f",turnaround_time*1.0/n);
- return 0;
- }
Add Comment
Please, Sign In to add comment