1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anestetic [448]
2 years ago
9

Before your shell forks a new process to call execvp(), it should parse the input string and separate it into a collection of su

bstrings representing the executable file and any command-line arguments. If the user entered an empty line, report an error and fetch a new line of input. Your code must handle at least four command-line arguments (in addition to the name of the executable file itself).
Computers and Technology
1 answer:
kompoz [17]2 years ago
3 0

Answer:

#define LSH_RL_BUFSIZE 1024

char *lsh_read_line(void)

{

int bufsize = LSH_RL_BUFSIZE;

int position = 0;

char buffer = malloc(sizeof(char) bufsize);

int c;

if (!buffer) {

   fprintf(stderr, "lsh: allocation error\n");

   exit(EXIT_FAILURE);

}

while (1) {

   // Read a character

   c = getchar();

   // If we hit EOF, replace it with a null character and return.

   if (c == EOF || c == '\n') {

     buffer[position] = '\0';

     return buffer;

   } else {

     buffer[position] = c;

   }

   position++;

   // If we have exceeded the buffer, reallocate.

   if (position >= bufsize) {

     bufsize += LSH_RL_BUFSIZE;

     buffer = realloc(buffer, bufsize);

     if (!buffer) {

       fprintf(stderr, "lsh: allocation error\n");

       exit(EXIT_FAILURE);

     }

   }

}

}

Explanation:

You might be interested in
What is rapid prototyping?​
yan [13]

Answer:

Rapid prototyping is the fast fabrication of a physical part, model or assembly using 3D computer aided design.

6 0
3 years ago
Successful implementation of an effective MRP system depends upon (1) the recognition of the difference between independent and
MakcuM [25]

Answer:

c. inventory control systems

Explanation:

During implementation of MRP system we have to consider <em>inventory control systems</em> because these systems track inventory levels, orders, sales, and deliveries. Therefore they must be considered.

5 0
3 years ago
Write down the functions of network layer in your own words.ASAP
sergeinik [125]
Hrhnebevevebnenebebenene
8 0
2 years ago
1. The following programs require using arrays. For each, the input comes from standard input and consists of N real numbers bet
Mamont248 [21]

Answer:

import java.util.*;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.Arrays;

class GFG

{

  // Function for calculating mean

  public static double findMean(double a[], int n)

  {

      int sum = 0;

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

          sum += a[i];

 

      return (double)sum / (double)n;

  }

  // Function for calculating median

  public static double findMedian(double a[], int n)

  {

      // First we sort the array

      Arrays.sort(a);

      // check for even case

      if (n % 2 != 0)

      return (double)a[n / 2];

 

      return (double)(a[(n - 1) / 2] + a[n / 2]) / 2.0;

  }

  public static double findMode(double a[], int n)

{

// The output array b[] will

// have sorted array

//int []b = new int[n];

 

// variable to store max of

// input array which will

// to have size of count array

double max = Arrays.stream(a).max().getAsDouble();

 

// auxiliary(count) array to

// store count. Initialize

// count array as 0. Size

// of count array will be

// equal to (max + 1).

double t = max + 1;

double[] count = new double[(int)t];

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

{

count[i] = 0;

}

 

// Store count of each element

// of input array

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

{

count[(int)(10*a[i])]++;

}

 

// mode is the index with maximum count

double mode = 0;

double k = count[0];

for (int i = 1; i < t; i++)

{

if (count[i] > k)

{

k = count[i];

mode = i;

}

}

return mode;

}

public static double findSmallest(double [] A, int total){

Arrays.sort(A);

return A[0];

}

 

public static void printAboveAvg(double arr[], int n)

{

 

// Find average

double avg = 0;

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

avg += arr[i];

avg = avg / n;

 

// Print elements greater than average

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

if (arr[i] > avg)

System.out.print(arr[i] + " ");

System.out.println();

}

 

public static void printrand(double [] A, int n){

Arrays.sort(A);

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

System.out.print(A[0]+"/t");

}

System.out.println();

}

 

public static void printHist(double [] arr, int n) {

 

for (double i = 1.0; i >= 0; i-=0.1) {

System.out.print(i+" | ");

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

 

// if array of element is greater

// then array it print x

if (arr[j] >= i)

System.out.print("x");

 

// else print blank spaces

else

System.out.print(" ");

}

System.out.println();

}

// print last line denoted by ----

for(int l = 0; l < (n + 3); l++){    

System.out.print("---");

}

 

System.out.println();

System.out.print(" ");

 

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

System.out.print(arr[k]+" ");

}

}

  // Driver program

  public static void main(String args[]) throws IOException

  {

      //Enter data using BufferReader

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

double [] A = new double[100];

int i=0;

System.out.println("Enter the numbers(0.0-1.0) /n Enter 9 if u have entered the numbers. /n");

do

{

A[i++]=Double.parseDouble(br.readLine());

}while(A[i-1]==9);

      i--;

      System.out.println("Average = " + findMean(A,i) );

      System.out.println("Median = " + findMedian(A,i));

      System.out.println("Element that occured most frequently = " + findMode(A,i));

      System.out.println("number closest to 0.0 =" + findSmallest(A,i));

      System.out.println("Numbers that are greater than the average are follows:");

      printAboveAvg(A,i);

      System.out.println("Numbers in random order are as follows:");

      printrand(A,i);

      System.out.println("Histogram is bellow:");

      printHist(A,i);

  }

}

Explanation:

3 0
2 years ago
In the main function, define five variables of type int, named: first, second, third, fourth, and total. Also in the main functi
fiasKO [112]

Answer:

  1. import java.util.Scanner;
  2. public class num8 {
  3.    public static void main(String[] args) {
  4.    int first, second, third, fourth,total;
  5.    double decimalOne, decimalTwo, decimalTotal;
  6.    }
  7.    public static void getData(int first, int second, int third, int fourth, double decimalOne, double decimalTwo){
  8.        System.out.println("Enter the Values");
  9.        Scanner in = new Scanner(System.in);
  10.        first=in.nextInt();
  11.        second=in.nextInt();
  12.        third=in.nextInt();
  13.        fourth=in.nextInt();
  14.        decimalOne = in.nextDouble();
  15.        decimalTwo = in.nextDouble();
  16.    }
  17.    public static int computeTotal(int first, int second, int third){
  18.        return first+second+third;
  19.    }
  20.    public static int computeTotal(int first, int second, int third, int fourth){
  21.        return first+second+third+fourth;
  22.    }
  23.   public static double computeTotal(double decimalOne, double decimalTwo){
  24.        return decimalOne+decimalTwo;
  25.    }
  26.    public static void printAll( int first, int second, int third){
  27.        System.out.println("Number one, two and three are: "+first+" "+second+" "+third);
  28.    }
  29.    public static void printAll( int first, int second, int third, int fourth){
  30.        System.out.println("Number one, two and three and four are: "+first+" "+second+
  31.                " "+third+" "+fourth);
  32.    }
  33.   public static void printAll( int first, int second, int third, int fourth, int fifth){
  34.        System.out.println("Number one, two and three and four are: "+first+" "+second+
  35.                " "+third+" "+fourth+" "+fifth);
  36.    }
  37.    public static void printAll( double first, double second, double third){
  38.        System.out.println("Number one, two and three and four are: "+first+" "+second+
  39.                " "+third);
  40.    }
  41. }

Explanation:

This solution is provided in Java:

All the variable declarations are done in the main method (lines 3-6)

Eight methods as specified in the question are created (Lines 7, 17, 20, 23, 26, 29, 33 and 37).

Observe the concept of Method Overloading (i.e. methods with same name and return types but different parameter list)

8 0
3 years ago
Other questions:
  • An _________ is a phrase formed from the first letters of words in a set phrase or series of words a. Acronymic sentence c. Basi
    7·2 answers
  • When reading a ____ language, we use our understanding of the richness of the language's vocabulary to extract the meaning. geop
    10·1 answer
  • a reviewer is required to enter a reason in the comments field only when a candidate is recommended to be hired. which action ca
    8·1 answer
  • Enter a formula in cell b7 to calculate the average value of cells b2:b6
    13·1 answer
  • A _____ is a network that uses multiple access points to link a series of devices that speak to each other to form a network con
    10·1 answer
  • What is the best brand of folders
    13·2 answers
  • When a partition is formatted with a file system and assigned a drive letter it is called a volume?
    10·1 answer
  • What is the process viewing files in chrome web browser cache?
    6·1 answer
  • Whoever answers first gets lots of points
    14·2 answers
  • Files and folders in UNIX can be removed using the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!