Program code in C for M/M/1 queuing model
#include<stdio.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int lam,mu,n,i;
float l,lq,ls,wq,ws,rho,p[20];
clrscr();
printf("\nEnter value for lam=");
scanf("%d",&lam);
printf("\nEnter value for mu=");
scanf("%d",&mu);
printf("\nEnter value for n=");
scanf("%d",&n);
l=(float)lam/(lam-mu);
ws=(float)(lam/mu);
wq=(float)(ws-(1/mu));
lq=(float)(pow(mu,2)/((mu)*(mu-lam)));
rho=(float)lam/mu;
p[0]=(float)(1-(lam/mu));
for(i=1;i<n;i++)
p[i]=(float)(p[0]*(pow(rho,i)));
printf("\n\n\nThe calculated results are=\n");
printf("\n l=%f",l);
printf("\n ws=%f",ws);
printf("\n wq=%f",wq);
printf("\n lq=%f",lq);
printf("\n p=%f",p);
printf("\nThe probablities are!!\n");
for(i=0;i<n;i++)
printf("\np[%d]=\t%f",i,p[i]);
getch();
}
by Aanchal Gupta(MCA/4510/11)
Comments