Top 10 Programming Language to learn in 2023

Are you a programming enthusiast looking to stay ahead of the curve in 2023? With the ever-evolving tech landscape, keeping up with the Best Programming Language to learn can be a daunting task. Fear not, as we have compiled a list of the top 10 Programming Languages that you should consider learning in 2023. Python: This versatile language continues to dominate in 2023, with its ease of use, readability, and a vast library of modules. JavaScript: As web development grows increasingly popular, JavaScript remains a crucial player, with its ability to create dynamic and interactive web pages. Java: This language has stood the test of time and remains a popular choice for enterprise software development. C++: A staple in the gaming and systems development industries, C++ offers exceptional performance and memory management. Swift: Apple's preferred language for iOS app development, Swift continues to grow in popularity with its simplicity and reliability. R: As data science and machin

C++ Program For C-LOOK Disk Scheduling Algorithm | C++ Programming

C-LOOK Disk Scheduling Algorithm-

  • Circular-LOOK Algorithm is an improved version of the LOOK Algorithm.
  • Head starts from the first request at one end of the disk and moves towards the last request at  the other end servicing all the requests in between.
  • After reaching the last request at the other end, head reverses its direction.
  • It then returns to the first request at the starting end without servicing any request in between.
  • The same process repeats.


Advantages-

  • It does not causes the head to move till the ends of the disk when there are no requests to be serviced.
  • It reduces the waiting time for the cylinders just visited by the head.
  • It provides better performance as compared to LOOK Algorithm.
  • It does not lead to starvation.
  • It provides low variance in response time and waiting time.

Disadvantages-

  • There is an overhead of finding the end requests.


C++ program for C-LOOK Disk Scheduling Algorithm

#include <iostream>

#include <stdlib.h>

using namespace std;

class clook_disk

{

    int ref[100];

    int ttrk, cur, size, prev;

    int sort();

public:
    void getdata();

    void total_move();
};

int clook_disk::sort()

{

    int temp;

    for (int i = 0; i < size - 1; i++)

        for (int y = 0; y < size - 1; y++)

            if (ref[y] > ref[y + 1])

            {

                temp = ref[y];

                ref[y] = ref[y + 1];

                ref[y + 1] = temp;
            }

    for (int i = 0; i < size; i++)

        if (ref[i] > cur)

            return i;

    return size;
}

void clook_disk::getdata()

{

    cout << "Enter total number of tracks : ";

    cin >> ttrk;

    ttrk--;

    cout << "Enter the current position of head : ";

    cin >> cur;

    cout << "Enter previous position of head : ";

    cin >> prev;

    cout << "Enter the size of queue : ";

    cin >> size;

    cout << "Enter the request for tracks : ";

    for (int i = 0; i < size; i++)

        cin >> ref[i];
}

void clook_disk::total_move()

{

    int num = cur, move = 0, ind, dir = cur - prev;

    ind = sort();

    if (dir > 0)

    {

        for (int i = ind; i < size; i++)

        {

            move += ref[i] - num;

            num = ref[i];
        }

        if (ind != 0)

        {

            num = ref[0];

            cout << move << " ";

            for (int i = 0; i <= ind - 1; i++)

            {

                move += ref[i] - num;

                num = ref[i];
            }
        }
    }

    else

    {

        for (int i = ind - 1; i >= 0; i--)

        {

            move += num - ref[i];

            num = ref[i];
        }

        num = ref[size - 1];

        for (int i = size - 2; i >= ind; i--)

        {

            move += num - ref[i];

            num = ref[i];
        }
    }

    cout << "Total head movements : " << move;
}

int main()

{

    clook_disk clook;

    clook.getdata();

    clook.total_move();

    return 0;
}

You May Also Like:

C Program for SCAN disk scheduling algorithm 

C program for First Come First Serve (FCFS) disk scheduling algorithm | C Programming


C program for Shortest Seek Time Next Disk Scheduling Algorithm | C Programming


C++ program for LOOK Disk Scheduling Algorithm | C++ Programming


C Program for C-SCAN Disk Scheduling Algorithm | C Programming


C++ Program For C-LOOK Disk Scheduling Algorithm | C++ Programming

Comments

Popular posts from this blog

C program to Find Cartesian Product of Two Sets | C programming

Array in C Programming | C Programming

What is System? | SAD