#include <iostream>
using namespace std;
int main()
{
clrscr();
int n,i,a[5],b[5],bt;
float p;
cout<<"Enter no. of process : ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\nEnter Burst time of process "<<i+1<<" : ";
cin>>bt;
cout<<"Enter priority of process "<<i+1<<" : ";
cin>>p;
a[p-1]=bt;
}
p=0;
b[0]=a[0];
for(i=1;i<n;i++)
{
b[i]=b[i-1]+a[i];
}
for(i=0;i<n-1;i++)
{
p+=b[i];
}
cout<<"\nAverage Waiting Time = "<<p/n;
getch();
}
Download Code::Blocks C++ Source Code Here
explain the variables please
ReplyDelete