# Index

S.No
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.

Name Of Program
Generate Uniformly Distributed Random Numbers (Repetitive or
Non-Repetitive) using Quick and Dirty method.
Generate Uniformly Distributed Random Numbers (Repetitive or
Non-Repetitive) using Power Residue method.
Generate Non Uniformly Distributed Random Numbers from an
Exponential Distribution using Inverse Transformation.
Generate Non Uniformly Distributed Random Numbers from a
Normal Distribution using Box-Muller Transformation.
Generate Non Uniformly Distributed Random Numbers from
Poisson Distribution for any specified lambda.
Generate Non Uniformly Distributed Random Numbers from an
Erlang-m Distribution with a mean time (m*beta) units.
Simulation of Inventory System.
Simulation of a Pure-Pursuit Problem.
Find the Square-Root of 3 using Monte-Carlo Simulation.
To simulate chemical reactor
Simulation of CPM method
Simulation of Second Order Servo System using Runge Kutta
Integration formula
Implement Chi Square test
Simulation of A Single-Server Queuing System

Signature

Program #1
AIM: Generate Uniformly Distributed Random Numbers (Repetitive or Non-Repetitive)
using Quick and Dirty method.

INPUT PARAMETERS: (Limits) a, b; (Number of Random Numbers) n
OUTPUT PARAMETERS: (Random Numbers Array) random
ROUTINES USED: rand()
SOURCE CODE:
#include <stdio.h>
float seed;
float rand()
{
int temp;
seed = (seed + 3.14159) * (seed + 3.14159);
temp = seed;
seed = seed - temp;
return (seed);
}
int main()
{
int n,a,b;
int choice,i,j,*random;
while (1)
{
printf ("Options:\n");
printf ("1. Repetitive\n");
printf ("2. Non Repetitive\n");
printf ("3. Exit\n");
scanf ("%d", &choice);
if (choice == 3)
return 0;
if ((choice < 1) || (choice > 3))
{
printf ("Wrong choice...Enter Again.\n");
continue;
}
printf ("\nEnter the required number of random numbers:\t");

scanf ("%d", &n);
random = (int*) malloc(n);
printf ("Enter the limits:\t");
scanf ("%d%d", &a, &b);
seed= 0.714563;
printf (“Random Number are:\n");
for (i=0; i<n; i++)
{
random[i] = a + ((b-a) * rand());
if (choice = = 2)
{
for (j=0; j<i; j++)
{
if (random[i] == random[j])
{
i--;
break;
}
}
}
}
for (i=0; i<n; i++)
{
printf ("%d\n",random[i]);
}
free (random);
}
}

OUTPUT
Options:
1. Repetitive
2. Non Repetitive
3. Exit

1

Enter the required number of random numbers: 20
Enter the limits:
25 75
Random Number are:
68
29
47
72

62 34 29 48 30 50 44 47 73 69 36 46 61 73 70 46 Options: 1. Exit Enter your choice 2 Enter the required number of random numbers: 20 Enter the limits: 25 75 Random Number are: 68 29 47 72 62 34 48 30 50 44 73 69 36 46 61 70 66 74 25 63 . Repetitive 2. Non Repetitive 3.

. scanf ("%d". B. printf ("Enter the limits:\t"). INPUT PARAMETERS: (Limits) A. long int m. b = sizeof(int)*8.h> int main() { int n. seed = m-1. B.h> #include <limits. (Number of Random Numbers) n OUTPUT PARAMETERS: (Random Numbers Array) random SOURCE CODE: #include <stdio. printf ("1. int a. b. A.\n"). printf ("3. *random. scanf ("%d%d". Repetitive\n").Enter Again.h> #include <math.(b/2)) + 3. int choice. continue. seed. printf ("2. j. a = pow(2. printf ("Enter your choice\t"). if ((choice < 1) || (choice > 3)) { printf ("Wrong choice.Program #2 AIM: Generate Uniformly Distributed Random Numbers (Repetitive or Non-Repetitive) using Power Residue method. m = pow(2. i. &choice). &B). &n). random = (int*) malloc(n).b-1).. &A. } printf ("\nEnter the required number of random numbers:\t"). Exit\n"). . double rand. Non Repetitive\n"). while (1) { printf ("Options:\n"). scanf ("%d". if (choice == 3) return 0.

} } } } for (i=0. Non Repetitive 3. Exit Enter your choice 1 Enter the required number of random numbers: 20 Enter the limits: 25 75 Random Number are: 74 72 64 32 66 54 28 30 . j++) { if (random[i] == random[j]) { i--. Repetitive 2. j<i. i++) { seed = (seed * a) % m.random[i]). } free (random). } } OUTPUT: Options: 1. i<n. break. i++) { printf ("%d\n". i<n. random[i] = A + ((B-A) * rand). if (choice == 2) { for (j=0. for (i=0. rand = (double)seed / m.printf ("Random Number are:\n").

Non Repetitive 3. Exit Enter your choice 2 Enter the required number of random numbers: 20 Enter the limits: 25 75 Random Number are: 74 72 64 32 66 54 28 30 48 37 68 71 41 47 62 53 39 59 49 61 . Repetitive 2.28 48 28 37 68 72 71 72 41 47 62 53 Options: 1.

14159). random = ((-1) / lambda) * log(u). printf ("Enter the value of lambda\t"). i<n. scanf ("%d".random). printf ("Random Numbers from an Exponential Distribution using Inverse Transformation are:\n").b. INPUT PARAMETERS: lambda. temp = seed.h> float seed = 0. clrscr(). printf ("\nEnter the required number of random numbers:\t"). &n). int i. i++) { u = rand(). float rand() { int temp.random.14159) * (seed + 3. } int main() { int n. seed = seed .714563.temp. seed = (seed + 3. float lambda. &lambda). (Number of Random Numbers) n OUTPUT PARAMETERS: (Random Numbers) random ROUTINES USED: rand() SOURCE CODE: #include <stdio. } . return (seed).h> #include <math.Program #3 AIM: Generate Non Uniformly Distributed Random Numbers from an Exponential Distribution using Inverse Transformation.u. printf ("%f\n".a. for (i=0. scanf ("%f".

return 0.194246 0.getch().036673 0.618378 0.013003 0. } OUTPUT: Enter the required number of random numbers: 10 Enter the value of lambda 3.602118 0.073690 0.437890 0.8 Random Numbers from an Exponential Distribution using Inverse Transformation are: 0.205916 0.627371 0.173405 .

rand2() SOURCE CODE: #include <stdio. seed1 = (seed1 + 3. seed2 = (seed2 + 3. return (seed2).714567.714563.14159) * (seed2 + 3. INPUT PARAMETERS: (Expected Mean) mu. return (seed1). float seed2 = 0.random.14159) * (seed1 + 3.sigma. float rand1() { int temp. &n).14159).b. scanf ("%d".u1. seed2 = seed2 . float mu. printf ("\nEnter the required number of random numbers:\t"). seed1 = seed1 .temp. temp = seed1. } float rand2() { int temp. } int main() { int n. printf ("Enter the Expected Mean(Mu) and Standard Deviation(Sigma):\n").h> #include <math.u2. temp = seed2.a. (Number of Random Numbers) n OUTPUT PARAMETERS: (Random Numbers) x ROUTINES USED: rand1().temp. (Standard Deviation) sigma. clrscr().14159). int i.Program #4 AIM: Generate Non Uniformly Distributed Random Numbers from a Normal Distribution using Box-Muller Transformation. .x.h> float seed1 = 0.

x).5 ) * cos(6. x = sigma * random + mu. &sigma). printf ("%f\n".358772 51.462170 . return 0.906258 38.283 * u2). random = pow( ( (-2) * log(u1) ).814940 22. printf ("Random Numbers from a Normal Distribution using Box-Muller Transformation are:\n"). i++) { u1 = rand1().233006 13. for (i=0.0.256416 22.875181 23.612061 53. u2 = rand2(). } OUTPUT: Enter the required number of random numbers: 10 Enter the Expected Value(Mu) and Standard Deviation(Sigma): 35 10 Random Numbers from a Normal Distribution using Box-Muller Transformation are: 38.059597 39. &mu. } getch().960373 44.scanf ("%f%f". i<n.

int i. return (seed). i<n.k. i++) { k = 0. float rand() { int temp. . } int main() { int n. scanf ("%f". for (i=0. (Number of Random Numbers) n OUTPUT PARAMETERS: (Random Numbers) k ROUTINES USED: rand() SOURCE CODE: #include <stdio. seed = (seed + 3. printf ("Enter the value of lambda\t"). seed = seed . temp = seed. printf ("\nEnter the required number of random numbers:\t").714563.14159).z. product = 1 * rand().h> #include <math. &n).14159) * (seed + 3. z = exp( (-1) * lambda). clrscr(). &lambda). printf ("Random Samples from a Poisson Distribution are:\n"). float lambda.temp. INPUT PARAMETERS: lambda. scanf ("%d".Program #5 AIM: Generate Non Uniformly Distributed Random Numbers from Poisson Distribution for any specified lambda. while (product >= z) { k++.product.h> float seed = 0.

} printf ("%d\n". return 0. } OUTPUT: Enter the required number of random numbers: 10 Enter the value of lambda 6 Random Samples from a Poisson Distribution are: 6 7 8 6 8 4 3 7 2 6 .product *= rand(). k). } getch().

&m. &beta). seed = seed .product. scanf ("%d". printf ("\nEnter the required number of random numbers:\t"). of services) m. clrscr(). j<m.14159) * (seed + 3.temp. temp = seed. (Average service time) beta. } .14159). return (seed). seed = (seed + 3. (Number of Random Numbers) n OUTPUT PARAMETERS: (Random Numbers) erlang ROUTINES USED: rand() SOURCE CODE: #include <stdio. for (j=0. printf ("Enter the number of services and average service time:\t").j.erlang.Program #6 AIM: Generate Non Uniformly Distributed Random Numbers from an Erlang-m Distribution with a mean time (m*beta) units.h> #include <math. &n). } int main() { int n. j++) { product *= rand().m. float beta.h> float seed = 0. i++) { product = 1. scanf ("%d%f". i<n. printf ("Random Samples from an Erlang-m Distribution are:\n"). float rand() { int temp.714563. int i. INPUT PARAMETERS: (No. for (i=0.

} getch(). } OUTPUT: Enter the required number of random numbers: 10 Enter the number of services and average service time: 3 Random Samples from an Erlang-m Distribution are: 23 13 37 16 11 8 7 29 22 11 7 . printf ("%d\n". erlang). return 0.erlang = (-1) * beta * log(product).

temp. float cost.Program #7 AIM: Simulation of Inventory System. } int main() { int point. int stock. demand. &quantity). No more units due. return (seed). float rand() { int temp. quantity. equi_stock.h> #include <math. temp = seed.. seed = seed . int i.add quantity ordered to stock. due_date. (Re-Order Quantity) quantity OUTPUT PARAMETERS: (Total Cost Incurred) cost ROUTINES USED: rand() SOURCE CODE: #include <stdio.7614593.. due_date = 0. seed = (seed + 3. scanf ("%d%d". printf ("Enter Re-Order Point & Re-Order Quantity\n"). INPUT PARAMETERS: (Re-Order Point) point. &point.h> float seed = 0. units_due = 0. /*initialize values*/ cost = 0.14159) * (seed + 3. units_due.14159). /*Simulate for specified number of days(180)*/ for(i=1. */ . i++) { /* If today(i) is due date. i<=180. stock = 115.

} equi_stock = stock + units_due. Reorder Quantity */ if (equi_stock <= point ) { units_due = quantity.stock) * 18.0). stock -= demand. /* If demand is more than stock. units_due = 0.000000 . stock = 0. cost). return 0.75). /* If equivalent stock is less than equal to Reorder Point..if (due_date == i) { stock += quantity. add loss of gud-will cost to cost*/ if (demand > stock) { cost += ((demand . getch().. due_date += 3. } } printf (" Total Cost incurred: %f". /* add cost of placing reorder to cost */ cost += 75. } /* else add carrying cost to cost */ else { cost += (stock * 0. } demand = (int) rand() * 100. } OUTPUT: Enter Re-Order Point & Re-Order Quantity 300 350 Total Cost incurred: 142098.

} xf[t+1] = xf[t] + vf * (xb[t] .yf[15]. (Intial Position of Fighter) xf[0]. t<=12.Program #8 AIM: Simulation of a Pure-Pursuit Problem.. vf. printf ("Enter velocity of Fighter plane. dist SOURCE CODE: #include <stdio. return 0. (t+1). .2) ). yf[0]. &yf[0]). fire. float dist. t<=12. &xb[t].\n").i. /*Calculate distance for each new position of fighter plane*/ for (t=0.xf[t]) / dist. &vf).t). scanf("%f%f"... INPUT PARAMETERS: (Path of bomber) xb. t++) { dist = sqrt( pow((yb[t] .\n").xf[t]) . &xf[0]. (Velocity of Fighter) vf OUTPUT PARAMETERS: (Time and Position at which target is caught) t.yf[t]) . /* If distance between Fighter and Bomber is less than 10kms. dist). for (t=0. &yb[t]).h> int main() { float xb[15]. } printf ("Enter the Initial Position of Fighter in xy-coordinates. scanf ("%f%f". int t. xf[15].3f mts apart\n".. t++) { printf ("At time %d:\t".h> #include <math..\t"). scanf ("%f". yb .yb[15]. printf ("Enter the path of Bomber in xy-coordinates.2) + pow((xb[t] .*/ if (dist < 10) { printf ("Target caught at time: %d mins and %5.

return 0.yf[t]) / dist. At time 0: 80 0 At time 1: 90 -2 At time 2: 99 -5 At time 3: 108 -9 At time 4: 116 -15 At time 5: 125 -18 At time 6: 133 -23 At time 7: 141 -29 At time 8: 151 -28 At time 9: 160 -25 At time 10: 169 -21 At time 11: 179 -20 At time 12: 180 -17 Enter the Initial Position of Fighter in xy-coordinates.yf[t+1] = yf[t] + vf * (yb[t] ... 0 50 Enter velocity of Fighter plane. getch()...pursuit is abondoned!! */ printf ("Target Escaped.969 mts apart .. } OUTPUT: Enter the path of Bomber in xy-coordinates.\n"). } /* Target is not caught till end of specified time. 20 Target caught at time: 10 mins and 2..

temp. sqrt3).. i<n. float random.p=0.714565.sqrt3. return (seed). float rand() { int temp. printf ("\n The Square root of 3 is: %5. printf ("Enter the size of random sample you want to generate. &n).h> #include <math.3f\n". getch(). temp = seed. /* Count No.\t"). } .h> float seed = 0. seed = seed . } int main() { int i. of samples satisfying the boundary condition.*/ if ( (random*random) < 3) p++. i++) { random = rand() + 1.Program #9 AIM: Find the Square-Root of 3 using Monte-Carlo Simulation. scanf ("%d". INPUT PARAMETERS: (Size of random sample) n OUTPUT PARAMETERS: (Square-Root of 3) sqrt3 ROUTINES USED: rand() SOURCE CODE: #include <stdio. clrscr().14159) * (seed + 3. seed = (seed + 3. return 0.14159). for (i=0. } sqrt3 = 1 + (float)p/n..n.

OUTPUT: Enter the size of random sample you want to generate.727 .. 1250 The Square root of 3 is: 1.

000000 1.a[i].600000 0.0.000000 46.400000 0.774204 76.330185 39.774208 27.001015 34.100000 A[I] B[I] 100.800000 0. t = t+ 0.300000 0. b[0]= 50. float t=0.c[50]. k2 = .i<50.000001 15. float a[50].002911 .b[50].487724 47.c[i]). for( i=0.722519 31.008.b and c at different time instants SOURCE CODE: //chemical reactor void main() { int i.055008 74. k1 = .0.716244 44.Program #10 AIM: To simulate chemical reactor INPUT PARAMETERS: Initial amounts of a and b OUTPUT PARAMETERS: The amount of a.0.935013 51.479309 24.k1*a[i]*b[i])*delta.900000 1.722511 79.200000 0.330181 86. printf("TIME A[I] B[I] C[I]\n"). c[0] = 0.655876 29. a[0] = 100.344252 26.468800 89.030962 C[I] 0. c[i+1] = c[i] + (2*(k1*a[i]*b[i]) -k2*c[i])*delta.k2.961378 32.delta. } OUTPUT TIME 0.523750 84. } getch().100000 0.575649 40.002.468803 42. b[i+1] = b[i] +( k2*c[i] .064001 21.523758 36.055016 26.096008 54.000000 96.000000 92.000000 0.k1*a[i]*b[i])*delta.t.1.700000 0.479303 73.000000 50.001003 81. delta = .655872 77.b[i].500000 0.i++) { printf(" %f %f %f %f\n".012260 36. float k1.1.030968 23. a[i+1] = a[i] +( k2*c[i] .000000 8.

307180 4.277618 66.599999 3.899999 2.478569 89.299999 3.866231 9.408212 10.200000 1.670353 54.399998 4.400000 2.259979 62.021576 .824458 56.1.477516 57.071069 4.706978 13.286917 5.409818 8.599998 4.866241 59.138962 70.505721 14.484314 4.350017 9.977683 3.477502 7.865757 54.408222 60.603644 11.462898 88.350025 59.526802 79.959820 63.706985 63.799999 2.752705 55.978886 8.978897 58.547321 56.000717 92.100000 2.356575 92.421394 78.199998 4.268588 6.000000 2.552452 81.513920 55.500000 2.568970 80.916122 88.186707 57.237839 91.286938 55.400000 1.484337 54.499998 4.099998 4.547306 6.400116 90.463093 19.200000 2.722420 85.899998 71.865734 4.977043 84.300000 2.603653 61.481392 82.463097 69.138452 3.321411 68.822418 57.513900 5.699998 4.863250 10.799999 3.700000 2.258759 73.799998 4.824482 21.399999 3.277615 16.822406 7.505730 64.683270 59.247734 77.268604 56.699999 3.321411 18.160786 61.003992 5.863258 60.983200 89.186696 7.736404 87.828865 91.950432 90.571716 58.900000 2.299998 4.500000 1.455982 63.586712 65.696587 93.841057 56.359550 83.415298 69.959812 13.696190 70.341217 87.899998 3.307201 54.571706 8.262192 67.360817 65.977707 53.600000 2.499999 3.409828 58.600000 1.004009 55.800000 1.750275 72.262192 17.999999 3.696184 20.259971 12.199999 3.429169 86.628120 92.987417 11.099747 86.568581 67.700000 1.000282 76.138474 53.672897 75.150772 56.360811 15.300000 1.999998 4.987427 61.841040 6.099999 3.150757 6.190384 83.670330 4.071091 54.752686 5.

EST[8].h> #include<math.fn.h> int main() { int n=7.fnode.Program #11 AIM: Simulation of CPM method INPUT PARAMETERS: s[8].ENT[6]. cin>>f[i].i<=7.f[8]. double s[8]. cout<<"****CRITICAL PATH METHOD****\n\n". } cout<<"\n Read Duration for Activity"<<endl. double LNT[6]. cin>>s[i].m=5.i++) { cout<<"Starting node for Activity"<<i<<":".LFT[8] SOURCE CODE: #include<iostream.h> #include<conio.LST[8].EFT[8]. cout<<"\n".t[8] OUTPUT PARAMETERS: ENT[6].LFT[8]. double t[8].LST[8].i++) { cout<<"Finishing node for Activity"<<i<<":".sn.i<=7. for(int i=1. int snode.LNT[6]. cout<<"\n". for(i=1.EFT[8].i++) { cout<<"Duration for Activity"<<i<<":".tmin.f[8]. clrscr(). } . cin>>t[i].EST[8].h> #include<stdio. cout<<"Read Starting nodes for each activity"<<endl. cout<<"\n". } cout<<"\n Read Finishing nodes for each activity"<<endl.tmin. int mark[8]. for(i=1.i<=7.

j++) { cout<<EST[j]<<". if(EFT[k]>ENT[fnode]) { ENT[fnode]=EFT[k]. for(j=1.i++) { ENT[i]=0.". cout<<"EST"<<"=(". for(int j=1. fnode=f[k].i<=5.j++) { cout<<ENT[j]<<". for(j=1.j<=5. } cout<<")".j<=7.". EFT[k]=EST[k]+t[k]. . while(k<=n) { snode=s[k].j++) { cout<<EFT[j]<<". cout<<endl<<"EFT"<<"=(". cout<<endl<<"ENT"<<"=(". } cout<<")". EST[k]=ENT[snode].". } cout<<")".j<=7. cout<<"TMIN"<<":"<<tmin<<endl. } tmin=ENT[m]. } int k=1.for(i=1. } k=k+1.

} cout<<")". mark[d]=0. LST[d]=LFT[d]-t[d]. for(j=1. for(j=1. cout<<endl<<"LFT"<<"=(".j<=7. .q++) { LNT[q]=tmin.for(int q=1. cout<<"\n Critical path is"<<endl. LFT[d]=LNT[fn].l<=5. if(LST[d]<LNT[sn]) { LNT[sn]=LST[d]. } d=d-1. while(d>0) { sn=s[d]. for(int l=1. fn=f[d].j++) { cout<<LST[j]<<".j<=7. cout<<endl<<"LNT"<<"=(". double h. } cout<<"\n LST"<<"=(".j++) { cout<<LFT[j]<<".". } int d=7.q<=5.l++) { cout<<LNT[l]<<". } cout<<")".". } cout<")".".

return 0.e++) { h=abs(LST[e]-EST[e]).2 Duration for Activity3:6.5 Duration for Activity5:15. cout<<e.0 Duration for Activity4:4.8 Duration for Activity6:0 . if(h==0) { mark[e]=1. } OUTPUT: ****CRITICAL PATH METHOD**** Read Starting nodes for each activity Starting node for Activity1:1 Starting node for Activity2:1 Starting node for Activity3:2 Starting node for Activity4:2 Starting node for Activity5:3 Starting node for Activity6:3 Starting node for Activity7:4 Read Finishing nodes for each activity Finishing node for Activity1:2 Finishing node for Activity2:3 Finishing node for Activity3:4 Finishing node for Activity4:3 Finishing node for Activity5:5 Finishing node for Activity6:4 Finishing node for Activity7:5 Read Duration for Activity Duration for Activity1:5.for(int e=1.1 Duration for Activity2:7. } } getch().e<=7.

9.9) LFT= (5. 25. 5. 9.6.4. 13. 16.9. 5.4) Critical path is 1 4 5 .1.5 TMIN: 25.6.6.6) ENT= (0.1.1. 9. 22. 25.4. 25. 0. 25.9. 22. 9.6. 22.6.1. 22.1.1) EFT= (5.1.4) LST= (0. 22. 5.1. 5.1. 2. 7.4. 9.6.9. 11.4 EST= (0. 11. 9.4) LNT= (0.2. 25. 11. 9.6.6.6. 9.Duration for Activity7: 2.9. 5.9.1. 9.

5*u11))).y2.t.i<=n.5*u21)))*(y2+(0.y2). t=t+h.h> #include<stdio. u41=h*(y2+u32). cout<<"****SIMULATION OF SERVO SYSTEM****\n". float u11.5*u21))*(y1+(0.1.u22. h=0. } getch(). u22=h*(a*(1-(y1+(0.5)*u12)-(y1+(0.n.5)*u22)-(y1+(0.2f\n".y1. printf("%.u12.u31. u32=h*(a*(1-(y1+(0.5*u21))). } .u21. n=20.y1. u42=h*(a*(1-(y1+u31)*(y1+u31))*(y2+u32)-(y1+u31)).Program #12 AIM: Simulation of Second Order Servo System using Runge Kutta Integration formula OUTPUT PARAMETERS: t.5*u22)).u32. u31=h*(y2+(0.1.5*u12)). for(int i=1. a=0.t.5*u11)))*(y2+(0. y2=y2+((u12+(2*u22)+(2*u32)+u42)/6).2f\t\t%. u12=h*(a*(1-(y1*y1))*y2-y1). cout<<"Time(t)"<<"\t\t"<<"Y1"<<"\t\t"<<"Y2"<<endl.u42.u41.y2 SOURCE CODE: #include<iostream. u21=h*(y2+(0.a.5*u11))*(y1+(0.2f\t\t%.h> #include<conio. t=0.i++) { u11=h*y2.y1.h> int main() { float h. y2=0. y1=1. y1=y1+((u11+(2*u21)+(2*u31)+u41)/6). return 0. clrscr().

90 -0.91 1.00 0.70 -0.82 -0.37 -1.26 -1.60 0.60 -0.03 .62 -0.50 0.06 1.54 -0.80 0.03 1.70 -0.OUTPUT: ****SIMULATION OF SERVO SYSTEM**** Time(t) Y1 Y2 0.06 -1.00 0.92 -0.20 0.86 1.00 1.39 0.30 0.48 0.00 1.96 -0.96 1.35 -0.00 0.30 0.40 0.50 0.65 0.76 -0.10 0.90 0.16 -1.40 0.05 1.05 -1.80 1.10 0.20 0.10 1.98 -0.30 0.00 -0.20 0.06 1.05 1.73 0.15 -1.70 0.45 -0.27 -1.80 -0.57 0.88 -0.

i<cl. } for(i=0.17}.34}.3.7}.chi_sq. {75.i++) { if(temp<a[i][1]) { break.6}}.23. for(i=0.Program #13 AIM: Implement Chi Square test INPUT PARAMETERS: cl. {95.90}. temp+=pj/ex[i].73}.33}.5.09}. {25. int cl.h> #include<conio. scanf("%f%f". {.&ex[i]. } . scanf("%d". float ob[10]={0}.11.4.i.16. } for(i=0.000000.pj. {5. {90. {50.1.5. {99.i<11.i++) { pj=ob[i]-ex[i].h> #include<math.ob[10] OUTPUT PARAMETERS: a[11][2] SOURCE CODE: #include<stdio.ex[10]={0}. pj=pj*pj.2.7}.h> void main() { float a[11][2]={{99. {10.9}. {1.i++) { printf("\nenter expected and observed value of class %d ". printf("\nenter how many classes are there ").&ob[i]).&cl).ex[10].temp=0.21.5.8.i<cl.14.4}.i+1).

5 level of confidence that random no's are uniformly distributed .} printf("\n%f level of confidence that random no's are uniformly distributed ".a[i] [0]). getch(). } OUTPUT: enter how many classes are there 10 enter expected and observed value of class 1 500 468 enter expected and observed value of class 2 500 519 enter expected and observed value of class 3 500 480 enter expected and observed value of class 4 500 495 enter expected and observed value of class 5 500 508 enter expected and observed value of class 6 500 426 enter expected and observed value of class 7 500 497 enter expected and observed value of class 8 500 515 enter expected and observed value of class 9 500 463 enter expected and observed value of class 10 500 529 99.

} for(i=0.10. } cdt[i]=cat[i]+wt[i]+st[i].30. wt[i]=dif.ql[20]. } else { ql[i]=ql[i-1]-1.10.Program #13 AIM: Simulation of A Single-Server Queuing System OUTPUT PARAMETERS: I.10.cat[20]. } . cdt[0]=20.5}.ql[i].cat[20]. wt[i]=0.i<=8.wt[i]).cat[i].15.i. int i. id[i]=0.15.10}.5.i<=7. cat[0]=0. ql[0]=0.h> void main() { int at[8]={0. id[i]=-dif.wt[20]. int st[8]={20.15.cdt[20].i<=7.h> #include<conio.i++) cat[i]=cat[i-1]+at[i]. for(i=1. for(i=1.id[i]. if(dif>0) { ql[i]=ql[i-1]+1.5.ql[20].wt[20].dif.10.cdt[20].35. getch().id[20].i.i++) { dif=cdt[i-1]-cat[i].id[20] SOURCE CODE: #include<stdio.15. id[0]=0.i++) printf("\ni=%d\tcat=%d\tcdt=%d\tid=%d\tql=%d\twt= %d".cdt[i].

OUTPUT: ***** 1 SERVER ***** JOB 1 AT=0 CAT=0 ST=20 CDT=20 IDT=0 QL=0 JOB 2 AT=10 CAT=10 ST=15 CDT=35 IDT=0 QL=1 JOB 3 AT=15 CAT=25 ST=10 CDT=45 IDT=0 QL=1 JOB 4 AT=35 CAT=60 ST=5 CDT=65 IDT=15 QL=0 JOB 5 AT=30 CAT=90 ST=15 CDT=105 IDT=25 QL=0 JOB 6 AT=10 CAT=100 ST=15 CDT=120 IDT=0 QL=1 JOB 7 AT=5 CAT=105 ST=10 CDT=130 IDT=0 QL=1 JOB 8 AT=5 CAT=110 ST=10 CDT=140 IDT=0 QL=2 .