Needs a Topic

# What is 15 p in a rt?

###### Wiki User

###### July 04, 2009 12:54AM

15 players in a rugby team

## Related Questions

###### Asked in BMW

### What is a BMW RT-P 1100?

###### Asked in Math and Arithmetic

### What is the value of p in the quadratic equation p2 plus 13p-30 equals 0?

The solution is
p = +2 or p = -15 .
Here is how to get it.
p2 + 13p - 30 = (p - 2) ((p + 15)
So, if p2 + 13p - 30 = 0 then (p - 2) ((p + 15) = 0.
The product of two numbers equals 0 if and only one of the factors
is zero.
so solve the linear equations:
p -2 = 0 and p + 15 = 0 and get
p = +2 or p = -15 .

###### Asked in C Programming

### How do you write c program for CPU scheduling algorithms?

This is perfectly executing code.
#include<stdio.h>
int n, start;
struct process
{
int id;
int at,st,et,bt,tat,wt,flag,rt,priority;
}p[10],temp,q[10];
void display();
void fcfs();
void sjf();
void sjfpre();
void priority();
void prioritypre();
void main()
{
int i,j,min,u,ch;
printf("\nEnter the total no. of processes:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n enter the process id:");
scanf("%d",&q[i].id);
printf("\n enter process arrival time:");
scanf("%d",&q[i].at);
printf("\n enter process burst time:");
scanf("%d",&q[i].bt);
printf("\n enter the priority of the process:");
scanf("%d",&q[i].priority);
q[i].flag=0;
q[i].rt=q[i].bt;
}
do
{
for(i=0;i<n;i++)
{
p[i]=q[i];
}
min=999;
for(i=0;i<n;i++)
{
if(p[i].at<min)
{
min=p[i].at;
u=i;
}
// p[i].rt=p[u].bt;
}
start=p[u].at;
printf("\n1. fcfs");
printf("\n2.sjf");
printf("\n3.sjfpre");
printf("\n4.priority");
printf("\n5.prioritypre");
printf("\n6 exit");
printf("\n enter your choice:");
scanf("%d",&ch);
switch(ch)
{
case 1: fcfs();
break;
case 2: sjf();
break;
case 3: sjfpre();
break;
case 4: priority();
break;
case 5: prioritypre();
break;
// case 6: exit 0;
// break;
}
if(ch!=6)
display();
}while(ch!=6);
}
void display()
{
float turn=0, wait=0;
int i;
printf("\nprocess\tarrivaltime\tbursttime\tstarttime\tendtime\tpriority\twaitingtime\tturnaroundtime");
for(i=0;i<n;i++)
{
p[i].tat=p[i].et-p[i].at;
p[i].wt=p[i].tat-p[i].bt;
wait=wait + p[i].wt;
turn=turn + p[i].tat;
printf("\n%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",p[i].id,p[i].at,p[i].bt,p[i].st,p[i].et,p[i].priority,p[i].wt,p[i].tat);
}
wait=wait/n;
turn=turn/n;
printf("\nAverage waiting time is: %f",wait);
printf("\nAverage turnaround time is: %f",turn);
}
void fcfs()
{
int i,j;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(p[i].at>p[j].at)
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
}
}
start=p[0].at;
for(i=0;i<n;i++)
{
if(start<p[i].at)
start=p[i].at;
p[i].st=start;
p[i].et=start + p[i].bt;
start=p[i].et;
}
}
void sjf()
{
int i,j,min,u;
for(j=0;j<n;j++)
{
min=999;
for(i=0;i<n;i++)
if(p[i].at<=start && p[i].bt < min &&
p[i].flag==0)
{
min=p[i].bt;
u=i;
}
if(min==999)
{
for(i=0;i<n;i++)
if(p[i].at<min && p[i].flag==0)
{
min=p[i].at;
u=i;
}
start=p[u].at;
}
p[u].st=start;
p[u].et=start + p[u].bt;
p[u].flag=1;
start=p[u].et;
}
}
void sjfpre()
{
int i,j=0,min,u;
while(j<n)
{
min=999;
for(i=0;i<n;i++)
if(p[i].at<=start && p[i].rt<min &&
p[i].flag==0)
{
min=p[i].rt;
u=i;
}
if(min==999)
{
for(i=0;i<n;i++)
if(p[i].at<min && p[i].flag==0)
{
min=p[i].at;
u=i;
}
start=p[u].at;
}
if(p[u].bt==p[i].rt)
p[u].st=start;
p[u].rt=p[u].rt-1;
start=start+1;
if(p[u].rt==0)
{
p[u].et=start;
p[u].flag=1;
j++;
}
}
}
void priority()
{
int i,j,min,u;
for(j=0;j<n;j++)
{
min=999;
for(i=0;i<n;i++)
if(p[i].at<=start && p[i].priority < min
&& p[i].flag==0)
{
min=p[i].priority;
u=i;
}
if(min==999)
{
for(i=0;i<n;i++)
if(p[i].at<min && p[i].flag==0)
{
min=p[i].at;
u=i;
}
start=p[u].at;
}
p[u].st=start;
p[u].et=start + p[u].bt;
p[u].flag=1;
start=p[u].et;
}
}
void prioritypre()
{
int i,j=0,min,u;
while(j<n)
{
min=999;
for(i=0;i<n;i++)
if(p[i].at<=start && p[i].priority<min &&
p[i].flag==0)
{
min=p[i].priority;
u=i;
}
if(min==999)
{
for(i=0;i<n;i++)
if(p[i].at<min && p[i].flag==0)
{
min=p[i].at;
u=i;
}
start=p[u].at;
}
if(p[u].bt==p[i].rt)
p[u].st=start;
p[u].rt=p[u].rt-1;
start=start+1;
if(p[u].rt==0)
{
p[u].et=start;
p[u].flag=1;
j++;
}
}
}
code written by : Fabianski Benjamin