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
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
February 8th, 2010 at 7:22 pm
error in d prog
u hav not defined et[i]
February 18th, 2010 at 9:36 am
#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();
}
March 4th, 2010 at 6:11 pm
Thanx for this site
March 30th, 2010 at 5:21 pm
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
April 14th, 2010 at 8:52 pm
Very good,i
May 10th, 2010 at 1:12 pm
program is nice……….
but et[] should be replaced by pt[] in the line 23 and 29.
May 26th, 2010 at 2:56 am
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);
}
June 1st, 2010 at 6:13 pm
//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();
}
July 26th, 2010 at 12:37 pm
ET[i] should be replaced by pt[i]. and pt[i] should be declared……….
December 1st, 2010 at 10:25 pm
et[i]should be replaced y pt[i],pt[i] should be declared
………..progm is nice
December 1st, 2010 at 10:27 pm
et[i]should be replaced y pt[i],pt[i] should be declared
………..progm is nice
January 7th, 2011 at 10:06 am
#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;
}
January 7th, 2011 at 10:11 am
#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();
}
January 7th, 2011 at 10:15 am
it
works
January 21st, 2011 at 7:27 pm
program is good some errors are there
January 30th, 2011 at 1:09 pm
Where is “process.h”?
whew!
February 3rd, 2011 at 7:47 pm
hi friends i want c program for B.E. 4th sem os lab please help
February 18th, 2011 at 4:28 pm
hi friends i want to c program for B.tech 4th sem os lab program
April 3rd, 2011 at 6:53 pm
pls help me getting the program of fcfs (non primitive)
July 19th, 2011 at 11:14 am
Really Nice one…Thanks friends
July 25th, 2011 at 7:04 am
this is very useful…
THANK U!!!!!!!!
August 6th, 2011 at 9:06 pm
very good
August 26th, 2011 at 12:17 am
#include
#include
#include
void main()
{
char p[10][5];
int avg_wt=0,avg_tt=0,at[10],bt[10],tt[10],i,n,sp[10],ep[10];
sp[0]=ep[0]=tt[0]=0;
clrscr();
printf(“enter no of processes:”);
scanf(“%d”,&n);
for(i=1;i<n+1;i++)
{
printf("\nenter process %d name:\t",i);
scanf("%s",&p[i]);
printf("enter process Arrival time:\t");
scanf("%d",&at[i]);
printf("enter process Burst Time:\t");
scanf("%d",&bt[i]);
}
printf("\nProcss Name\t\tWaiting Time\t\tTurnaround Time\n");
for(i=1;i<n+1;i++)
{
sp[i]=ep[i-1];
ep[i]=sp[i]+bt[i];
tt[i]=(sp[i]-at[i])+bt[i];
avg_wt+=sp[i]-at[i];
avg_tt+=tt[i];
printf("\n%s\t\t\t%d\t\t\t%d\n",p[i],(sp[i]-at[i]),tt[i]);
}
printf("\nAverage Waiting Time=\t\t%f\n\nAverage Turnaround Time=\t%f",(float)avg_wt/n,(float)avg_tt/n);
getch();
}
September 2nd, 2011 at 5:41 pm
#include
#include
void main()
{
int n,c[20],wt[20],tat[20],i;
float avwt=0.0,avtat=0.0; clrscr();
printf(“Enter the no of process”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf("\n\nEnter the Cpu Brust process for %d process\t",i);
scanf("%d",&c[i]);
}
wt[i]=0;
for(i=2;i<=n;i++)
{
wt[i]=wt[i-1]+c[i-1];
}
for(i=1;i<=n;i++)
{
avtat=avtat+tat[i];
}
for(i=1;i<=n;i++)
{
avwt=avwt+wt[i];
avtat=avtat+tat[i];
}
avwt=avwt/n;
avtat=avtat/n;
printf("\n\nThe process are\n\n");
printf("process");
printf("\tWaiting time");
printf("\tTurn Around Time");
for(i=1;i<=n;i++)
{
printf("\n\np[%d]",i);
printf("\t%d",wt[i]);
printf("\t\t%d",tat[i]);
}
printf("\n\n\nAvg total time %f",avtat);
printf("\nAvg waiting time %f",avwt);
getche();
}
September 17th, 2011 at 5:54 pm
please help me..i need a code. round robin and non pre-emptive with a arrival time..
email me…thanks.
christiangilaquino@yahoo.com
September 17th, 2011 at 5:56 pm
please help me..i need a code. round robin and non pre-emptive including the arrival time..
email me…thanks.
christiangilaquino@yahoo.com
October 27th, 2011 at 6:37 am
Can we do the same for multiple processors.
November 1st, 2011 at 1:51 pm
its Good……………..
November 28th, 2011 at 6:30 pm
i dun think there is ny need of 2-d array ! “p[10][5]“
December 25th, 2011 at 9:24 am
hi frnds ple corect the folowing program
#include
{
int p1,p2,p3,p4;
int p[1]=2.p[2]=10,p[3]=14,p[4]=16;
printf(“the cpu burset time is =”,p[1],p[2],p[3],p[4]);
scanf(“%d”,&p[1]&,p[2]&,p[3]&,p[4]);
for(i=1;i<=4;i++)
{
int x[0],p[0]=0;
waiting timex[i]=x[i-1]+p[i-1];
}
printf("waiting time of cpu is=",&x1);
printf("waiting time of cpu is=",&x2);
printf("waiting time of cpu is=",&x3);
printf("waiting time of cpu is=",&x4);
average time is a=x[4]/4;
printf("average time is=",&a);
}
December 26th, 2011 at 3:39 pm
i like dis…..
December 26th, 2011 at 3:40 pm
i like this
December 26th, 2011 at 3:51 pm
if u have any doubts contact me
i will help u ……
All are worst fellows……..
December 26th, 2011 at 4:11 pm
niyab denga dani ke puteru ra meeru.
December 26th, 2011 at 4:14 pm
hey you stupid fellow ranjit
don’t u no how to write the lab programs
December 26th, 2011 at 4:16 pm
main()
{
int a,k,sum=0,i,n;
clrscr();
printf(“enter the dick size);
scanf(“%d”,&a);
n=a;
while(n!=0)
{
k=n%10;
sum=sum+k;
n=n/10;
}
printf(“\nvachi na madda gudandi ra);
getch();
}
December 26th, 2011 at 4:17 pm
this is the correct program
December 26th, 2011 at 4:19 pm
my name is billa
b for billa
bizidi billa
merupe saynyamla vastadilla
January 4th, 2012 at 11:18 am
#include
#include
int n,bu[20],ch=0;
float twt,awt,wt[20],tat[20];
void main()
{
void getdata();
void fcfs();
do
{
switch(ch)
{
case 0:
printf(“\n0.MENU”);
printf(“\n1.Getting BurstTime”);
printf(“\n2.FirstComeFirstServed”);
printf(“\n3.EXIT”);
break;
case 1:
getdata();
break;
case 2:
printf(“FIRST COME FIRST SERVED SCHEDULING”);
fcfs();
break;
case 3:
exit(0);
break;
}
printf(“\nEnter your choice:”);
scanf(“%d”,&ch);
getch();
}while(ch<4);
}
void fcfs()
{
int i,b[10];
float sum=0.0;
twt=0.0;
for(i=1;i<=n;i++)
{
b[i]=bu[i];
printf("\nBurst time for process p %d =",i);
printf("%d",b[i]);
}
wt[1]=0;
for(i=2;i<=n;i++)
{
wt[i]=b[i-1]+wt[i-1];
}
for(i=1;i<=n;i++)
{
twt=twt+wt[i];
tat[i]=b[i]+wt[i];
sum+=tat[i];
}
awt=twt/n;
sum=sum/n;
printf("\nTotal Waiting Time= %f",twt);
printf("\nAverage Waiting Time= %f",awt);
printf("\nAverage Turnaround time=%f",sum);
}
void getdata()
{
int i;
printf("Enter the no of processes:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter The BurstTime for Process p %d =",i);
scanf("%d",&bu[i]);
}
}
January 4th, 2012 at 11:31 am
#include
#include
int n,bu[20],ch=0;
float twt,awt,wt[20],tat[20];
void main()
{
void getdata();
void fcfs();
void sjf();
do
{
switch(ch)
{
case 0:
printf(“\n0.MENU”);
printf(“\n1.Getting BurstTime”);
printf(“\n2.ShortestJobFirst”);
printf(“\n3.EXIT”);
break;
case 1:
getdata();
break;
case 2:
printf(“SHORTEST JOB FIRST SCHEDULING”);
sjf();
break;
case 3:
exit(0);
break;
}
printf(“\nEnter your choice:”);
scanf(“%d”,&ch);
getch();
}while(ch<4);
}
void sjf()
{
int i,j,temp,b[10];
float sum=0.0;
twt=0.0;
for(i=1;i=1;i–)
{
for(j=2;jb[j])
{
temp=b[j-1];
b[j-1]=b[j];
b[j]=temp;
}
}
}
wt[1]=0;
for(i=2;i<=n;i++)
{
wt[i]=b[i-1]+wt[i-1];
}
for(i=1;i<=n;i++)
{
twt=twt+wt[i];
tat[i]=b[i]+wt[i];
sum+=tat[i];
}
awt=twt/n;
sum=sum/n;
printf("\nTotal Waiting Time=%f",twt);
printf("\nAverage Waiting Time=%f",awt);
printf("\nAverage turnaround time=%f",sum);
}
void getdata()
{
int i;
printf("Enter the no of processes:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter The BurstTime for Process p %d =",i);
scanf("%d",&bu[i]);
}
}
January 5th, 2012 at 6:58 am
very good
January 7th, 2012 at 10:07 am
tnx 4 ths site
January 7th, 2012 at 10:08 am
tnx 4 ths syt
January 7th, 2012 at 10:44 am
can i have the same program with strucures?
January 10th, 2012 at 5:56 pm
those programs are not correct. pt[] should be declared .
January 16th, 2012 at 12:19 am
frnz plz i need the fcfs program and algorithm.help me
January 16th, 2012 at 12:21 am
Can u also help me in the following plz it an urgent assignment
(1)Critical-section(program and algorithm)(small program)
(2)Dining philosopher(program and algorithm)(small program)
(3)Bakers (program and algorithm)(small program)
January 19th, 2012 at 4:26 pm
re puku JENI, niku pani madda ledu ra lamdi kodaka,ma srinath gadi madda naku vachi……………
thks fort dis site ………………..
January 28th, 2012 at 11:48 am
Please help me ,,give me example of LCFS(last come first serve)
January 31st, 2012 at 7:11 pm
#include
#include
void main()
{
int n,c[20],wt[20],tat[20],i;
float avwt=0.0,avtat=0.0; clrscr();
printf(“Enter the no of process”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
printf("\n\nEnter the Cpu Brust process for %d process\t",i);
scanf("%d",&c[i]);
}
wt[i]=0;
for(i=2;i<=n;i++)
{
wt[i]=wt[i-1]+c[i-1];
}
for(i=1;i<=n;i++)
{
avtat=avtat+tat[i];
}
for(i=1;i<=n;i++)
{
avwt=avwt+wt[i];
avtat=avtat+tat[i];
}
avwt=avwt/n;
avtat=avtat/n;
printf("\n\nThe process are\n\n");
printf("process");
printf("\tWaiting time");
printf("\tTurn Around Time");
for(i=1;i<=n;i++)
{
printf("\n\np[%d]",i);
printf("\t%d",wt[i]);
printf("\t\t%d",tat[i]);
}
printf("\n\n\nAvg total time %f",avtat);
printf("\nAvg waiting time %f",avwt);
getche();
}
January 31st, 2012 at 7:12 pm
hi friends i dont know large programs pls give some examples to my mail its a humble request