GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add files via upload · bappasahabapi/Algorithm.cpp@a9640b3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • fcfs.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎fcfs.cpp‎

Copy file name to clipboard
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include<iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n_process ,bt[20], wt[20], tat[20], avwt=0, avtat=0,avct =0, i, j;
8+
int ct[20];
9+
cout<<"Enter total number of processes(maximum 20):";
10+
cin>>n_process;
11+
12+
cout<<"\nEnter Process Burst Time\n";
13+
for(i=0; i<n_process ;i++)
14+
{
15+
cout<<"Process["<<i+1<<"]:";
16+
cin>>bt[i];
17+
}
18+
19+
wt[0]=0; //waiting time for first process is 0
20+
21+
//calculating waiting time
22+
for(i=1;i<n_process;i++)
23+
{
24+
wt[i]=0;
25+
26+
for(j=0; j<i; j++)
27+
wt[i]+=bt[j];
28+
}
29+
30+
//compleating time
31+
for(i=0; i<n_process; i++)
32+
{
33+
ct[i]= bt[i];
34+
for(j=0; j<i; j++)
35+
ct[i]+=bt[j];
36+
37+
}
38+
39+
cout<<"\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time\tCompleating Time\t ";
40+
41+
//calculating turnaround time
42+
for(i=0; i<n_process; i++)
43+
{
44+
tat[i]=bt[i]+wt[i];
45+
avwt+=wt[i];
46+
avtat+=tat[i];
47+
avct+=ct[i];
48+
cout<<"\nP["<<i+1<<"]"<<"\t\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i]<<"\t\t"<<ct[i];
49+
}
50+
51+
avwt/=i;
52+
avtat/=i;
53+
cout<<"\n\nAverage Waiting Time:"<<avwt;
54+
cout<<"\nAverage Turnaround Time:"<<avtat;
55+
cout<<"\nAverage Compleating Time:"<<avct<<endl;
56+
57+
return 0;
58+
}
59+

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.