Ideas Solution Code
#include <iostream> #include <time.h> #include <stdlib.h> using namespace std; const int rows = 10; const int cols = 10; int selectOption(){ int choice = 0; cout<<"Press 1 to populate a two-dimensional array with integers from 1 to 100\n"; cout<<"Press 2 to display the array elements\n"; cout<<"Press 3 to display the largest element present in the array along with its row and column index\n"; cout<<"Press 4 to find and show the transpose of the array\n"; cout<<"Press 5 To Exit\n"; cout<<"\nPlease select an option, use numbers from 1 to 5: "; do { cin>>choice; if(choice >= 1 && choice <= 5){ break; } else { cout<<"\nChoice should be between 1 and 5\n"; cout<<"Invalid choice, please select again: "; } } while(true); cout<<"___________________________________________________\n"; return choice; } // end selectOption function void populateArray(int data[rows][cols]){ srand(time(0)); for(int i = 0; i < rows; i++){ for(int j = 0; j < cols; j++){ data[i][j] = rand() % 100 + 1; } } cout<<"Array populated sucessfully\n"; } // end of poulateArray function void showElements(int data[rows][cols]){ for(int i = 0; i < rows; i++){ for(int j = 0; j < cols; j++){ cout<<data[i][j]<<"\t"; } cout<<endl; } } // end of showElements function void showLargestElement(int data[rows][cols]){ int largest = 1, row =0, col = 0; for(int i = 0; i < rows; i++){ for(int j = 0; j < cols; j++){ if(data[i][j] > largest){ largest = data[i][j]; row = i; col = j; } } } cout<<"Largest element is "<<largest<<" which is at row = "<<row+1<<" or index = "<<row<<" and column "<<col+1<<" or index "<<col<<endl; } // end of showLargestElement function void transposeArray(int data[rows][cols]){ for(int i = 0; i < cols; i++){ for(int j = 0; j < rows; j++){ cout<<data[j][i]<<'\t'; } cout<<endl; } } // end of transposeArray function main(){ int choice = 0, data[rows][cols] = {0}; do{ choice = selectOption(); switch(choice){ case 1: cout<<endl; populateArray(data); cout<<endl; break; case 2: if(data[0][0] == 0){ cout<<"\nSorry the array is empty, first populate it by pressing 1 to perform this task"<<endl<<endl<<endl; continue; } cout<<endl; showElements(data); cout<<endl; break; case 3: if(data[0][0] == 0){ cout<<"\nSorry the array is empty, first populate it by pressing 1 to perform this task"<<endl<<endl<<endl; continue; } cout<<endl; showLargestElement(data); cout<<endl; break; case 4: if(data[0][0] == 0){ cout<<"\nSorry the array is empty, first populate it by pressing 1 to perform this task"<<endl<<endl<<endl; continue; } cout<<endl; transposeArray(data); cout<<endl; break; } }while(choice != 5); // end of do-while loop } // end of main functionCS604 Assignment 2 Solution and Discussion Spring 2020
-
Re: CS604 Assignment 2 Solution and Discussion
Operating Systems (CS604)
Assignment # 02
Spring 2020
Total marks = 15Deadline Date
14th June 2020Please carefully read the following instructions before attempting assignment.
RULES FOR MARKING
It should be clear that your assignment would not get any credit if:
The assignment is submitted after the due date.
The submitted assignment does not open or file is corrupt.
Strict action will be taken if submitted solution is copied from any other student or from the internet.You should consult the recommended books to clarify your concepts as handouts are not sufficient.
You are supposed to submit your assignment in .doc or docx format.
Any other formats like scan images, PDF, zip, rar, ppt and bmp etc will not be accepted.Objective:
• The objective of this assignment is to learn scheduling algorithm.
• To learn and understand different Operating System structure.NOTE
No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its closing date.
If you find any mistake or confusion in assignment (Question statement), please consult with your instructor before the deadline. After the deadline no queries will be entertained in this regard.
For any query, feel free to email at:
[email protected]Question No 01 15 marks
Consider the following set of processes, with the CPU burst time given in milliseconds:Process Burst Time
P1 10
P2 1
P3 2
P4 1
P5 5The processes are arrived in the order P1, P2, P3, P4, P5, all at time 0.
A. Draw Gantt chart showing the execution of these processes using FCFS and SJF scheduling.
B. Calculate the turnaround time of each process for FCFS scheduling algorithm as per part Calculation of part A?
C. Calculate the waiting time of each process for SJF scheduling algorithm as per calculation of Part A?Wish you very Best of Luck!
-
@zaasmi said in CS604 Assignment 2 Solution and Discussion Spring 2020:
Re: CS604 Assignment 2 Solution and Discussion
Operating Systems (CS604)
Assignment # 02
Spring 2020
Total marks = 15Deadline Date
14th June 2020Please carefully read the following instructions before attempting assignment.
RULES FOR MARKING
It should be clear that your assignment would not get any credit if:
The assignment is submitted after the due date.
The submitted assignment does not open or file is corrupt.
Strict action will be taken if submitted solution is copied from any other student or from the internet.You should consult the recommended books to clarify your concepts as handouts are not sufficient.
You are supposed to submit your assignment in .doc or docx format.
Any other formats like scan images, PDF, zip, rar, ppt and bmp etc will not be accepted.Objective:
• The objective of this assignment is to learn scheduling algorithm.
• To learn and understand different Operating System structure.NOTE
No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or internet malfunctioning etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file at least two days before its closing date.
If you find any mistake or confusion in assignment (Question statement), please consult with your instructor before the deadline. After the deadline no queries will be entertained in this regard.
For any query, feel free to email at:
[email protected]Question No 01 15 marks
Consider the following set of processes, with the CPU burst time given in milliseconds:Process Burst Time
P1 10
P2 1
P3 2
P4 1
P5 5The processes are arrived in the order P1, P2, P3, P4, P5, all at time 0.
A. Draw Gantt chart showing the execution of these processes using FCFS and SJF scheduling.
B. Calculate the turnaround time of each process for FCFS scheduling algorithm as per part Calculation of part A?
C. Calculate the waiting time of each process for SJF scheduling algorithm as per calculation of Part A?Wish you very Best of Luck!
-
@zaasmi said in CS604 Assignment 2 Solution and Discussion Spring 2020:
C. Calculate the waiting time of each process for SJF scheduling algorithm as per calculation of Part A?
-
@zaasmi said in CS604 Assignment 2 Solution and Discussion Spring 2020:
B. Calculate the turnaround time of each process for FCFS scheduling algorithm as per part Calculation of part A?
-
@zaasmi said in CS604 Assignment 2 Solution and Discussion Spring 2020:
A. Draw Gantt chart showing the execution of these processes using FCFS and SJF scheduling.


100% Off on Your FEE Join US! Ask Me How?


