OUTPUT:
enter no of processes: 5
enter process1 name: aaa
enter process time: 4
enter process2 name: bbb
enter process time: 3
enter process3 name: ccc
enter process time: 2
enter process4 name: ddd
enter process time: 5
enter process5 name: eee
enter process time: 1
p_name P_time w_time
aaa 4 0
bbb 3 4
ccc 2 7
ddd 5 9
eee 1 14
total waiting time=34
avg waiting time=6.80
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 | #include<stdio.h> #include<conio.h> #include<process.h> void main() { char p[10][5]; int tot=0,wt[10],i,n; float avg=0; clrscr(); printf("enter no of processes:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter process%d name:\n",i+1); scanf("%s",&p[i]); printf("enter process time"); scanf("%d",&pt[i]); } wt[0]=0; for(i=1;i<n;i++) { wt[i]=wt[i-1]+et[i-1]; tot=tot+wt[i]; } avg=(float)tot/n; printf("p_name\t P_time\t w_time\n"); for(i=0;i<n;i++) printf("%s\t%d\t%d\n",p[i],et[i],wt[i]); printf("total waiting time=%d\n avg waiting time=%f",tot,avg); getch(); } |
OUTPUT:
enter no of processes: 5
enter process1 name: aaa
enter process time: 4
enter process2 name: bbb
enter process time: 3
enter process3 name: ccc
enter process time: 2
enter process4 name: ddd
enter process time: 5
enter process5 name: eee
enter process time: 1
p_name P_time w_time
aaa 4 0
bbb 3 4
ccc 2 7
ddd 5 9
eee 1 14
total waiting time=34
avg waiting time=6.80
error in d prog
u hav not defined et[i]
#include
#include
#include
void main()
{
char p[10][5];
int tot=0,wt[10],i,n;
float avg=0;
clrscr();
printf(“enter no of processes:”);
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
printf("enter process%d name:\n",i+1);
scanf("%s",&p[i]);
printf("enter process time");
scanf("%d",&pt[i]);
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+et[i-1];
tot=tot+wt[i];
}
avg=(float)tot/n;
printf("p_name\t P_time\t w_time\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\n",p[i],et[i],wt[i]);
printf("total waiting time=%d\n avg waiting time=%f",tot,avg);
getch();
}
Thanx for this site
My name is Piter Jankovich. oOnly want to tell, that your blog is really cool
And want to ask you: is this blog your hobby?
P.S. Sorry for my bad english
Very good,i
program is nice……….
but et[] should be replaced by pt[] in the line 23 and 29.
Hi friends :
I chaneged this program a little,
It’s correct :
include
void main()
{
char p[10][5];
int tot=0,wt[10],pt[10],z,n,i;
float avg=0;
printf(“\nenter number of process : “);
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
printf("\nenter process %d name : ",i+1);
scanf("%s",&p[i]);
printf("enter process time : ");
scanf("%d",&pt[i]);
}
wt[0]=0;
for (i=1;i<n;i++)
{
wt[i]=wt[i-1]+pt[i-1];
tot=tot+wt[i];
}
avg=(float)tot/n;
printf("\np-name\tp-time\tw-time \n");
for (i=0;i<n;i++)
printf("%s\t%d\t%d\n",p[i],pt[i],wt[i]);
printf("\n total waiting time : %d \n avg wating time : %f \n\n ",tot ,avg);
}
//A program to FCFS
#include
#include
main()
{
int p[10],wt[10],bt[10],tat[10],ttat=0,twt=0,i,j,temp,n;
float awt,atat;
clrscr();
printf(“enter the no. of process=>”);
scanf(“%d”,&n);
printf(“enter process=>”);
for(i=0;i”);
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+bt[i-1];
twt=twt+wt[i];
}
for(i=0;i<n;i++)
{
tat[i]=wt[i]+bt[i];
ttat=ttat+tat[i];
}
awt=(float)twt/n;
atat=(float)ttat/n;
printf("p_number\t P_bt\t p_wt\t p_tat\n");
for(i=0;i<n;i++)
printf("%d \t\t %d\t %d\t %d\n",p[i],bt[i],wt[i],tat[i]);
printf("total waiting time=%d\n avg waiting time=%f",twt,awt);
printf("\ntotal turnedaroundtime=%d\n avg turnedaround time=%f",ttat,atat);
getch();
}
ET[i] should be replaced by pt[i]. and pt[i] should be declared……….
et[i]should be replaced y pt[i],pt[i] should be declared
………..progm is nice
et[i]should be replaced y pt[i],pt[i] should be declared
………..progm is nice
#include
using namespace std;
int main()
{
int k,p,b,wt=0,total;
cout<>p;
for(k=1;k<=p;k++)
{
cout<>b;
total=wt+b;
cout<<"\nprocess="<<k;
cout<<"\nburst time="<<b;
cout<<"\nwaiting time="<<wt;
cout<<"\nturn around time="<<total;
wt=wt+b;
total=wt+b;
}
return 0;
}
#include
#include
#include
void main()
{
char p[10][5];
int tot=0,wt[10],i,n;
float avg=0;
clrscr();
printf(“enter no of processes:”);
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
printf("enter process%d name:\n",i+1);
scanf("%s",&p[i]);
printf("enter process time");
scanf("%d",&pt[i]);
}
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=wt[i-1]+et[i-1];
tot=tot+wt[i];
}
avg=(float)tot/n;
printf("p_name\t P_time\t w_time\n");
for(i=0;i<n;i++)
printf("%s\t%d\t%d\n",p[i],et[i],wt[i]);
printf("total waiting time=%d\n avg waiting time=%f",tot,avg);
getch();
}
it
works
program is good some errors are there
Where is “process.h”?
whew!
hi friends i want c program for B.E. 4th sem os lab please help
hi friends i want to c program for B.tech 4th sem os lab program
Can you help me with Last Come, First Served (LCFS) or Last In, First Out (LIFO)
C program codes? Please. Many Thanks! 🙂
Fcfs ka algo in c me chahiye plz btaona
wrong prog recompile it 🙁
teeri maaa ki
its good to understand dude
hgafgsdrwteyyjhwhsjs jjshhsgd…………….??????????????”””””””””””
How can I write and run a FCFS algorithm using C++ knowing that these are the input info:
Process ,burst time , waiting time
(p1=burst 24 , wt 0)
(p2=burst 15 = wt 24)
(p3=burst 27, wt 39)
(p4=burst 16, wt 66)
(p5=burst 16, wt 82)
Compute average time of waiting time for all processes
Compute average time of turnaround time for all processes
turn in your program to compute both time waiting time and turnaround time.
The project at end will compute the average of both times to find best algorithm
help me please ..
Tried the same logic as shown.. but the problem arises with the total waiting time as well as average waiting time…
they appear to be 0 in both the cases..
Help me !! 🙁
shirtlu nehru garu poolu
adhaanlu naanlu!!!
Chikangoka
Spring roll
Kabapp
Vulkar
Pissaa
.
.
.
.
ituli vadaa pongaal dosaa
neelu ennalu panralu…! poilu aduthalu semlu vaalu….
neeelu indhalu collegelu continuelu pannalu mudiyathulu.. neelu veralu collgelu paarulu…
endha saarae party la enna kalichuu..
Saarae nyaan naan kalichuu..
pachae neenga kalichadhum ariyum, enna sapadu kalichuu
adhaan saarae naan thaan kalichuu..
hehehehehhhehee ariyum saarae nyan vilayatu ku paranchuu..
endha aayi saarae..
Comedy paranchuu…
(apdiyae serupala aranchuu…)
the code is wrong because
” et ” is not declare instead of it replace “et ” to “pt “
the code is wrong because
” et ” is not declare instead of it replace “et ” to “pt “
and
instead of char p[10][10]
write p[10]
………………………………………………. 🙂
i want fcfs program imediatly in java code
dis program iz rit bcoz dis is’ pt’=process time not ‘et’
begin
if(fcfs=-1)
print(“java”)
end
midfingzzzzzzzzzzzz
tumari ma ka choda mc na mili
programme C qui convert NTFS vers FAT 32 sans pert de donée & mercu d’avance
pt=et is write becoz when we globle declaired
Why turnaround time will be not found…lakhavu to badhu lakhavu harder…
FCFS scheduling algorithm describe very easily, to know details visite this link.
http://www.secufoon.com/describe-first-come-first-serve-scheduling-algorithmfcfs-in-c-language-concept/