Sunday 24 June 2012

c++ program to count total number of head movement using first come first served(FCFS) scheduling algorithm.

#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
    int n;
    cout<<"enter your queue size:";
    cin>>n;
    int ub,lb=0;
    cout<<"Enter your upper bound:";
    cin>>ub;
    int queue[3];
    int head;
    cout<<"Enter your head:";
    cin>>head;





    int temp,len=0,i,j;
    for(i=0;i<n;i++)
    {
        cout<<"enter value for queue:";
        cin>>queue[i];
   
    }
    prev=head;
    for(i=0;i<n;i++)
    {
        temp=abs(prev-queue[i]);
        len=len+prev;
        prev=queue[i];
    }
    cout<<endl<<"total ::";
    cout<<len;   
return 0;
}

ALSO YOU CAN SEE FOLLOWING PROGRAMS:-

No comments:

Post a Comment