#include<iostream>

using namespace std;


int main() {

    int n, i;

    float avg_wt, avg_tat;

    cout<<"Enter the number of processes: ";

    cin>>n;


    int burst_time[n], arrival_time[n], completion_time[n], waiting_time[n], turnaround_time[n];

    int service_time = burst_time[0];

    


    for(i=0;i<n;i++) {

        cout<<"Enter arrival time for Process "<<i+1<<": ";

        cin>>arrival_time[i];

        cout<<"Enter burst time for Process "<<i+1<<": ";

        cin>>burst_time[i];

    }


    completion_time[0] = burst_time[0] + arrival_time[0];

    for (int i = 1; i < n; i++) {

        

        waiting_time[i] = service_time - arrival_time[i];


        if (service_time < arrival_time[i])

            service_time = arrival_time[i] + burst_time[i];

        else

            service_time += burst_time[i];

    }

    turnaround_time[0] = burst_time[0] + waiting_time[0];

   // waiting_time[0] = turnaround_time[0] - burst_time[0];

    avg_wt = waiting_time[0];

    avg_tat = turnaround_time[0];


    for(i=1;i<n;i++) {

        completion_time[i] = completion_time[i-1] + burst_time[i];

      turnaround_time[i] = burst_time[i] + waiting_time[i];

       // waiting_time[i] = turnaround_time[i] - burst_time[i];

        avg_wt += waiting_time[i];

        avg_tat += turnaround_time[i];

    }


    cout<<"\nProcess\t\tArrival Time\tBurst Time\tCompletion Time\tWaiting Time\tTurnaround Time\n";

    for(i=0;i<n;i++) {

        cout<<"P"<<i+1<<"\t\t"<<arrival_time[i]<<"\t\t"<<burst_time[i]<<"\t\t"<<completion_time[i]<<"\t\t"<<waiting_time[i]<<"\t\t"<<turnaround_time[i]<<endl;

    }



    avg_wt /= n;

    avg_tat /= n;

    cout<<"\nAverage Waiting Time: "<<avg_wt;

    cout<<"\nAverage Turnaround Time: "<<avg_tat;


    return 0;

}





#include <iostream>

using namespace std;


void findWaitingTime(int n, int bt[], int wt[]) {

    wt[0] = 0; 

    int service_time = bt[0];

    for (int i = 1; i < n; i++) {

        

        wt[i] = service_time - 0;


        if (service_time < 0)

            service_time = 0 + bt[i];

        else

            service_time += bt[i];

    }

}


void findTurnAroundTime(int n, int bt[], int wt[], int tat[]) {

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

        tat[i] = bt[i] + wt[i]; 

}


void findAverageTime(int n, int bt[]) {

    int wt[n], tat[n], total_wt = 0, total_tat = 0;


   

    findWaitingTime(n, bt, wt);

    findTurnAroundTime(n, bt, wt, tat);


   

    for (int i = 0; i < n; i++) {

        total_wt += wt[i];

        total_tat += tat[i];

    }


    float avg_wt = (float)total_wt / (float)n;

    float avg_tat = (float)total_tat / (float)n;


    cout << "Average Waiting Time: " << avg_wt << endl;

    cout << "Average Turnaround Time: " << avg_tat << endl;

}


int main() {

    int n;

    cout << "Enter the number of processes: ";

    cin >> n;


    int bt[n];

    for (int i = 0; i < n; i++) {

        cout << "Enter  burst time for process " << i + 1 << ": ";

        cin >>  bt[i];

    }


    findAverageTime(n, bt);


    return 0;

}

prac.  


Here is an example program that initializes an array in 8085 assembly language ². 


```assembly

ORG 0000H

MOV C, 05H ; Load the counter with 5

LXI H, 2000H ; Load the starting address of the array

MOV A, 00H ; Load the value to be stored in the array

BACK: STAX B ; Store the value in memory location pointed by HL pair

INX H ; Increment the pointer

DCR C ; Decrement the counter

JNZ BACK ; Jump if not zero

HLT ; Terminate the program

```


This program initializes an array of size 5 starting from memory location 2000H with value 00H ².


Source: Conversation with Bing, 5/18/2023

(1) How to Initialize an array in Assembly Language - Stack Overflow. https://stackoverflow.com/questions/43696966/how-to-initialize-an-array-in-assembly-language.

(2) 8085 program to add numbers in an array - GeeksforGeeks. https://www.geeksforgeeks.org/8085-program-to-add-numbers-in-an-array/.

(3) 8085 program to add numbers in an array - Online Tutorials Library. https://www.tutorialspoint.com/8085-program-to-add-numbers-in-an-array.





MVI C,04H


LOOP1:


MOV B,C


;COUNTER IN REG C


INX H


SKIP:


DCR B


LXI H,1050H


JNZ LOOP2


LOOP2: MOVA,M


INX H


DCR C


CMP M


JNZ LOOP1


JC SKIP


HLT


; SWEPT DATA IF A IS GREATER THEN MEMORY DATA


MOV D,M


1050 22 53 45 11 89 00 00 00 00 00 00 00 00 00 00 00


MOV M,A


DCX H


1050 89 53 45 22 11 00 00 00 00 00 00 00 00 00 00 00


MOV M,D