Consider Context Switch time of 2 secs and modify below program accordingly Program: #include #include using namespace std; int main() { int p[20],bt[20], su[20], wt[20],tat[20],i, k, n, temp; float wtavg, tatavg; printf("Enter the number of processes---"); scanf("%d",&n); for(i=0;i
Q: Prepare a menu-driven C program for Inserting and deletion operations for a stack structure of…
A: c code : #include<stdio.h>#include<string.h>struct student{ char F_name[12]; char…
Q: Consider the following C++ code: static long z = 5 ; int d = 10 ; int *ptr1 = new int[2] ;…
A: Given: Consider the following C++ code: static long z = 5 ; int d = 10 ; int *ptr1 = new int[2] ;…
Q: Write a program in c to detect if the system will face any deadlock in the future. If a deadlock is…
A: CODE- //c Code//header files#include <stdio.h>//Global variable declarationint…
Q: When a C++ function is executing, where are local variables of the function allocated? Question…
A: When a C++ function is executing, where are local variables of the function allocated? Question…
Q: Please explain your reasoning. int bof(char *str, int size) { char *buffer = (char *)…
A: To some extent... If you are trying to use the malloc function then the memory that gets allocated…
Q: Course Title : Operating System Question : Paging is a memory management scheme that eliminates the…
A: (1) First error is space between the int and pos. I have corrected it in line 11. (2) Second error…
Q: Have I labeled the below code properly using the terms precedence, identifier scope, variable…
A: Here, you labeled the code properly using the terms precedence, identifier scope, variable lifetime,…
Q: Write a C code to Create Queue of Patients waiting to see the Physician in a clinic. Insert Patient…
A: Solution In order to ensure that patients are sorted from oldest to youngest, the priority queue…
Q: Write a C program to find the sum of all non-prime numbers from m and n (including m and n also)…
A: A number is said to be prime number if it has factors 1 and itself
Q: Trace the following Assembly program then answer the questions INCLUDE Irvine32.inc 3 .data 4 list…
A: INCLUDE Irvine32.inc .datalist byte 2,-3,12,0,-1.codemain PROC mov ecx, lengthof list mov esi,…
Q: int bof(char *str, int size) { char *buffer = (char *) malloc(size); strcpy(buffer, str);…
A:
Q: 15. Assuming the following C++ variable declaration statement int i = 2021, *pi = &i, **ppi = π…
A: Given: int i=2021,*pi = &i, **ppi = &pi; //here i is integer variable with value 2021 //pi…
Q: question: Question 4 Consider the following Python program (note that Python uses indentation to…
A: The variables accessible in the body of sub2() are a,x,w The variables a and w are local to the…
Q: 1 All of the following data values are examples of unsigned datatypes in HLA EXCEPT a uns32 b…
A: The above question is solved in step 2 :-
Q: plz do not copy from chegg #include using namespace std; void WaitingTime(int processes[], int n,…
A: This is required code. See below steps for complete code.
Q: # i need solution faster please in c++ or c # assume the processor has many processes that are…
A: Solution:- We can use priority queue that will maintain sorted processes, import java.util.*; class…
Q: Create a function that is executed in multiple stages (0 to i) For each stage i, generate all…
A: Shifting a list rotates its elements. Elements moved off the end are rotated to the beginning. For…
Q: d on the above program, create a function void priorityQueue ( pt current queue and insert new…
A: Hi please find the detailed explanation of the asked question step by step below: To Find: Write the…
Q: 2. Consider the two main variables: Number and N. Number is a 1024 byte variable. It represents a…
A: Answers Data types in C++ is mainly divided into three types: Primitive Data Types: These data…
Q: When a function is called in a given running program, an _____________ is created in the stack…
A: When a function is called in a given running program, an Area is created in the stack section of the…
Q: Write a program in some language that has both static and stackdynamic local variables in…
A: Since the programming language is not mentioned, so we'll do it in java. The programming methodology…
Q: 8. What is the result of the following program execution with the data and operations gi in main( ).…
A: Answer is The Stack is Empty 5 10 20 30 40 55 5 10 20 5 10 20 7 14 10 5 10 20 7 14 10 100
Q: averse, that produces the nodes of a data structure. 4 pts def traverse(self):
A: Suppose we have a function, traverse, that produces the nodes of a data structure. 4 pts def…
Q: This exercise involves printing out the generations of a series of processes created using fork().…
A: According to the information given:- We have to generate series of processes created using fork().
Q: Write a c++ code Shortest Job First (SJF) is a scheduling algorithm where CPU executes the shortest…
A: PROGRAM INTRODUCTION: The CPU is given to the process with the shortest burst duration first, out…
Q: QUESTION 4 a) Based on the codes given in Program-4, illustrate the memory address of the pointers…
A: The above question is solved in step 2 :-
Q: Exercise 1.4. Consider this code snippet: int a, b3B * *; x = &b; b =13B int a = +x + 1: Complete…
A: Given the lines of code. First let's understand them. int a,b int *x x= &b represents x contain…
Q: write a C programme in C language 9. (a) Sort the following data diagrammatically in descending…
A: As per guidelines, first question will be solved please upload another question again. Heap is known…
Q: Given the following function f, what will be the output of the function call f(3)? int f(int n){…
A: The problem contains 2 questions where : First question is related to calling a method and finding…
Q: For each of the following problems, all functions should be implemented using a call stack. Problem…
A: Code: #include<iostream>using namespace std; //function to merge a[0..n1-1] and b[0..n2-1]…
Q: 4. Write a program to sort the elements of 1D array in descending order and also implement linear…
A: NOTE: SINCE THE LANGUAGE FOR THE CODE WAS NOT MENTIONED, I HAVE USED C FOR THE SOLUTION Program…
Q: To write a COMPLETE C program) Prepare a menu-driven C program for Inserting and deletion…
A: CODE: #include<stdio.h> #include<string.h> struct student { char F_name[12];…
Q: Which of the following is NOT true? (Choose all that apply) 01. None II. A dangling pointer is an…
A: D) A Program with memory leak is free from creating garbage.
Q: 1. Write a line by line explanation to this program. 2. What does the program do? Explain. 3. What…
A: Step by step explanation: It is a SMALL MODEL, in the use of the memory model, the segment of the…
Q: You are responsible to write an assembly function to perform searching of a list of names in stored…
A: The ask is to convert the given code snippet in C to the x86-64 assembly. The snippet is o perform…
Q: Can you please help me with answering the following coding question? If you do write code, can it…
A: C Program is a basic level programming language that was developed to write low level programming.
Q: Write a C program to count Non-Armstrong numbers from m and n (including m and n also) using the…
A: #include <stdio.h> //Declare a function void calculate(int *m, int *n, int *count); int…
Q: Please make some changes in the code and make it unique #include int main() { // P0, P1,…
A: Code after required changes is as follows: #include <stdio.h> #define M 3#define N 3 int…
Q: 4. Write a program in C to create and display a circular linked list. Test Data : Input the number…
A: As per the given problem, we have to implement a program that creates and displays a circular linked…
Q: In C# Suppose variable nums contains a list of integers. List«Integer> nums = Arrays.asList(1, 1,…
A: The java streams are introduced in java version 8. The java streams are used for the computation of…
Q: READING CODE - STACK 2 47 mov al, 0; Return code of 0 mov ah, 4ch: Exit back to MSDOS int 21h list…
A: What is the purpose of lines 36 and 37? How does the assembler know where the start of the program…
Q: How many hexadecimal digits are used when representing a nibble in hex form? 01 0 3 02 00 Patti the…
A: The above question is solved in step 2 :-
Q: READING CODE - STACK ;list the output of the following program assuming the input is as follows: 3…
A: What register is at the top of the stack right after line 26?
Q: Merge two stacks into one stack. Split one stack into two stacks based on a condition.
A: Java is a high level programming language. And also object oriented . It. Is a platform for…
Q: Read through the following code segment. Suppose the code is successfully compiled and executed in a…
A: answer will be 4 8 8 Explanation: Fork tree is drawn below All the fork2 will print A and after…
Q: #include 2 #include void swap(int a, int b); int main(void) { int i=3, j=4; 6 swap(i, j); 7…
A: Here I have created the main method with 2 variables and then passed the address of the variables to…
Q: 2) Explain, which is the operation of following code fragment, W in C language INCLUDE "P18F242.INC"…
A: Actually, fragment is a small part of broken off, or separated from something.
Q: a. Write a line by line explanation for the following program. b. Write a short paragraph on what is…
A: Actually, assembly language program is a low level language.
Consider Context Switch time of 2 secs and modify below program accordingly
Program:
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
int p[20],bt[20], su[20], wt[20],tat[20],i, k, n, temp; float wtavg, tatavg;
printf("Enter the number of processes---"); scanf("%d",&n);
for(i=0;i<n;i++)
{
p[i] = i;
printf("Enter the Burst Time of Process %d---", i); scanf("%d",&bt[i]);
printf("System/User Process (0/1) ?---"); scanf("%d", &su[i]);
}
for(i=0;i<n;i++)
for(k=i+1;k<n;k++)
if(su[i] > su[k])
{
temp=p[i];
p[i]=p[k];
p[k]=temp;
temp=bt[i];
bt[i]=bt[k];
bt[k]=temp;
temp=su[i];
su[i]=su[k];
su[k]=temp;
}
wtavg = wt[0] = 0; tatavg = tat[0] = bt[0];
for(i=1;i<n;i++)
{
wt[i] =wt[i-1]+bt[i-1];tat[i] =tat[i-1]+ bt[i];
wtavg = wtavg + wt[i]; tatavg = tatavg + tat[i];
}
printf("\nPROCESS\t SYSTEM/USER PROCESS \tBURST TIME\tWAITING TIME\tTURNAROUND TIME"); for(i=0;i<n;i++)
printf("\n%d \t\t %d \t\t %d \t\t %d \t\t %d ",p[i],su[i],bt[i],wt[i],tat[i]);
printf("\nAverage Waiting Time is---%f",wtavg/n);
printf("\nAverage Turnaround Time is---%f",tatavg/n);
getch();
}
Step by step
Solved in 3 steps with 2 images
- Notice that although the illustrated polygon has only 6 distinct corners, n for this polygon is 7 because the algorithm expects that the last point (x6,y6) will be repeat of the initial point, (x0,y0).Define a structure for a point. Each point contains x coordinate and y coordinate. The representation of a Polygon must be a stack of structures in your program.Write a C program that takes the number of actual points (n-1) from the user. After that, user enters x and y coordinates of each point. (The last point will be repeat of the initial point).When you read the coordinates form the user, they are placed on your stack. In your computation, you will get the coordinates from the stack.Write a computeArea function which returns the area of the Polygon. Print the area of the Polygon in main. Display the area with two digits after the decimal point.Note: The absolute value can be computed with fabs function.Example: double x = - 5.0; fabs(x) is 5.0double x = 0.0; fabs(x) is 0.0double x =…Using HASKELL Define function sumProduct that receives a list of numbers and returns a pair, where the first component is the summation of the list elements, and the second component is the multiplication of the list elements. For example, if the input is [2,4,3,5] then the output is (14, 120).Write these in SML Write these functions in ML(SML) : Write a function dup to double each element of an integer list. One function only.dup([2,3,5]) → [2,2,3,3,5,5] Write a function dups to double each char of a string. Recursion must on list not string.dups("aabc") → "aaaabbcc" Write a function mid to keep elements of an integer list between 5 and 10. One function only.mid [12,3,6,4,5,1] → [6,5]
- Write in C Language Description F(x) = x + 1 G(x, y) = x + y Please write a program to calculate the value of composite of F and G Input Input will be the composite of F and G. The parameter of F and G are integer only. Output An integer represent the value of function. Sample Input 1 F(G(1,F(3))) Sample Output 1 6(To write a COMPLETE C program)Prepare a menu-driven C program for Inserting and deletion operations for a stack structure of student information which has the following structure declaration.struct student{ char F_name[12];char L_name[12];int Std_id;char Std_address[20];char Std_email[30];char Std_mobile[12];char department[2];/* CE=Computer Engineering, E=English */};struct stack{struct student std_info[10]; int top;};Define the following Initialized array of structure in your program.struct student COME205_Students [10]={”Ahmet” ,”Osman”, 12005310,”Gaziantep”,”Ahmet@gmail.com”,“05531001020”,“CE”,88,”Sevgi” ,”Mert”, 12005311,”Konya”,” Sevgi@gmail.com”,“05531141990”,“E”,81,”Osman”, ”Kemal”, 12005312,”Istanbul”,” Osman@gmail.com”,“05531331023”,“CE”,75,”Mert”, ”Osman”, 12005313, ”Antalya”,” Mert@gmail.com”,“05531041424”,“CE”,70,”Ayse”,”Omer”, 12005314,”Ankara”,” Ayse@gmail.com”,“05531087412”,“E”,80,”Kemal”, “ali”, 12005315, ”Izmir”,” Kemal@gmail.com”,“05535471028”,“CE”,88,”Lale”, ”Can”,…C++ Language: write code. and algorithm or related theory of the following question. Give secreenshoots. Narrative 2: We need to have a generic module which reads in file and gives the output in the format which would facilitate other programs to do comparison like the one we saw above to carry out analysis and comparison. Response Required: Write a program that reads a given text, outputs the text as is, and also prints the number of lines and the number of times each letter appears in the text. An uppercase letter and a lowercase letter are treated as being the same; that is, they are tallied together. Since there are 26 letters, we use an array of 26 components to perform the letter count. We also need a variable to store the line count. The text is stored in a file, which we will call textin.txt. The output will be stored in a file, which we will call textout.txt Input: A file containing the text to be processed. Output: A file containing the text, number of lines, and the number…
- Given a Stack class implementation, move first half of the stack to another stack? Merge two LLs into one LL. Split one LL into two LLs based on a condition. Merge two stacks into one stack. Split one stack into two stacks based on a condition. Data Structure C++ Please just write functions only. Dont write whole codeWrite a C++ program that reads the name, ID and average marks of 5 students using array of structures then print this list sorted alphabetically. The program must contain 3 functions for reading, printing and sorting?Write a program in some language that has both static and stackdynamic local variables in subprograms. Create six large (at least 100 * 100) matrices in the subprogram—three static and three stack dynamic. Fill two of the static matrices and two of the stack-dynamic matrices with random numbers in the range of 1 to 100. The code in the subprogram must perform a large number of matrix multiplication operations on the static matrices and time the process. Then it must repeatthis with the stack-dynamic matrices. Compare and explain the results.
- OCaml Code: Please fix all the errors needed for interpreter.ml and use the test cases to test the code. Make sure to give the correct code with the screenshots of the test cases passing the code. interpreter.ml type stackValue = BOOL of bool | INT of int | ERROR | STRING of string | NAME of string | UNIT type command = ADD | SUB | MUL | DIV | PUSH of stackValue | POP | REM | NEG | TOSTRING | SWAP | PRINTLN | QUIT let interpreter (input, output) = let ic = open_in input in let oc = open_out output in let rec loop_read acc = try let l = String.trim (input_line ic) in loop_read (l :: acc) with End_of_file -> List.rev acc in let strList = loop_read [] in let str2sv s = match s with | ":true:" -> BOOL true | ":false:" -> BOOL false | ":error:" -> ERROR | ":unit:" -> UNIT | _ -> let rec try_parse_int str = try INT…Implement in C Programming 9.5.1: LAB: Parsing dates Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not following that format is incorrect and should be ignored. Use the substring() function to parse the string and extract the date. The input ends with -1 on a line alone. Output each correct date as: 3-1-1990. Ex: If the input is: March 1, 1990 April 2 1995 7/15/20 December 13, 2003 -1 then the output is: 3-1-1990 12-13-2003 Use the provided GetMonthAsInt() function to convert a month string to an integer. If the month string is valid, an integer in the range 1 to 12 inclusive is returned, otherwise 0 is returned. Ex: GetMonthAsInt("February") returns 2 and GetMonthAsInt("7/15/20") returns 0. #include <stdio.h> #include <string.h> int GetMonthAsInt(char *monthString) { int monthInt; if (strcmp(monthString, "January") == 0) { monthInt = 1; } else if (strcmp(monthString, "February") == 0) {…Write a program in C++ that contains code addressing the following: (New code and with detailed steps!) a. Create an integer array of 100,000 items (static binding – before compiling) b. Create the same large array on the run time stack (in a function) c. Create the same large array from the heap (dynamic memory – dynamic binding). Call each of the subprograms 1,000,000 times and output the time required by each to finish all 1,000,000 calls. Which was the fastest? Here is code for calling time. #include <time.h> //in main() clock_t start = 0, end = 0; //variables start = clock(); //calls time function stores result in start end = clock(); // calls time function stores result in end //display the time by subtracting the start from the end //displays in clock ticks.