First Come First Serve (FCFS) Disk Scheduling Algorithm in C++



#include <iostream>

using namespace std;

int main()
{
    clrscr();
    int a,b,c=0,i=1;
    char ch='y';
    cout<<"enter value of initial head position : ";
    cin>>a;


    do
    {
        cout<<"enter value of cylinder : "<<i<<" : ";
        cin>>b;
        c+=abs(a-b);
        a=b;
        i++;
        cout<<"\nWant to enter more(y/n):";
        cin>>ch ;

    }while(ch!='n');

    cout<<" \nTotal head movement = "<<c<<" cylinders";
    getch();
}

Download Code::Blocks C++ Source Code Here

No comments:

Post a Comment

Custom Search