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
Ganezh [65]
3 years ago
10

Consider the partially-filled array named a. What does the following loop do? (cin is a Scanner object)int[] a = {1, 3, 7, 0, 0,

0};int size = 3, capacity = 6;int value = cin.nextInt();while (value > 0){a[size] = value;size++;value = cin.nextInt();}1. May crashe at runtime because it can input more elements than the array can hold2. Reads up to 3 values and inserts them in the array in the correct position.3. Reads one value and places it in the remaining first unused space endlessly.4. Reads up to 3 values and places them in the array in the unused space.
Computers and Technology
1 answer:
boyakko [2]3 years ago
8 0

Answer:

Option 1: May crash at runtime because it can input more elements than the array can hold

Explanation:

Given the code as follows:

  1.        int[] a = {1, 3, 7, 0, 0, 0};
  2.        int size = 3, capacity = 6;
  3.        int value = cin.nextInt();
  4.        while (value > 0)
  5.        {
  6.            a[size] = value;
  7.            size++;
  8.            value = cin.nextInt();
  9.        }

From the code above, we know the <em>a</em> is an array with six elements (Line 1). Since the array has been initialized with six elements, the capacity of the array cannot be altered in later stage.

However, a while loop is created to keep prompting for user input an integer and overwrite the value in the array started from index 3 (Line 4- 9). In every round of loop, the index is incremented by 1 (Line 7). If the user input for variable <em>value</em> is always above zero, the while loop will persist.  This may reach a point where the index value is out of bound and crash the program. Please note the maximum index value for the array is supposedly be 5.  

You might be interested in
When you are working on an unsaved document on a PC, where is the document temporarily saved?
Serga [27]

Answer:

RAM

Explanation:

RAM or Random Access Memory is a volatile storage memory which means if a power is turned off and turned on again it will be clear, that is why, if we do not save our work and a power failure occurs, our data is lost. It is where all our running programs are located while we are working. There is another memory, which is ROM(Read Only Memory). This is a non-volatile storage and saved work is stored in ROM.

3 0
3 years ago
Write a function called committee to compute the number of ways of forming a single committee with r members from a collection o
andrezito [222]

Answer:

This program is written in C++.  The explanation of the code is given below in the explanation section.

Explanation:

#include <iostream>

using namespace std;

//factorial calculation

int fact(int n) {

  if (n == 0 || n == 1)

     return 1;

  else

     return n * fact(n - 1);

}

int main() {

  int n, r, comb; /* n represent number of people (population), r represent the number of selection from population and combination represent number of ways or combination */

  cout<<"Enter n : ";// prompt user to enter population i.e. total number of people

  cin>>n;//store into n

  cout<<"\nEnter r : ";//prompt user to enter number of selection from population

  cin>>r;

  comb = fact(n) / (fact(r) * fact(n-r));// calcuate combination- number of differnt ways to form a committe

  cout << "\nCombination : " << comb; //show the result

  return 0;

}

5 0
3 years ago
A network administrator is using packet tracer to mock up a network that includes iot devices. What can the administrator do fro
Vikki [24]

Answer:

give some instructions for iot device

Explanation:

on how to go about something that you would be able to control physically

6 0
3 years ago
Plzzzz help!!!
Len [333]

Answer:

Record:

"Contains information related to a specific person or other entity"

Report:

"Is generated by running a query"

<u>"Can be in the form of a table or a graph"</u>

Querie:

"Is used to retreieve information from a database"

"Can contain filters"

<u>"Appears horizontally in a table"</u>

Explanation:

THE ONES THAT I UNDERLINED ARE THE ONES IM UNSURE ABOUT

5 0
3 years ago
What is the minimum number of locations a sequential search algorithm will have to examine when looking for a particular value i
Alecsey [184]

Answer:

O( n ) of the 100 element array, where "n" is the item location index.

Explanation:

From the meaning of the word "sequential", the definition of this algorithm should be defined. Sequential donotes a continuously increasing value or event, like numbers, increasing by one in an arithmetic progression.

A list in programming is a mutable data structure that holds data in indexed locations, which can be accessed linearly or randomly. To sequentially access a location in a list, the algorithm starts from the first item and searches to the required indexed location of the search, the big-O notation is O( n ), where n is the index location of the item searched.

4 0
3 years ago
Other questions:
  • Write code to complete print_factorial()'s recursive case. sample output if user_val is 5: 5! = 5 * 4 * 3 * 2 * 1 = 120
    15·1 answer
  • Prior to the release of a movie, a film studio launches a website that allows people to play online games featuring actors in th
    15·2 answers
  • What type of camera is a cell phone camera
    14·2 answers
  • Which would take more storage space, a layer file showing all the us counties or a layer file showing all the us states?
    8·1 answer
  • What does the do not disturb button do on the iphone?
    12·1 answer
  • Simpson is trying to solve an equation related to converting a decimal number to its hexadecimal form. He decides to utilize the
    6·1 answer
  • 2. A _______
    9·1 answer
  • How does one select an entrepreneurial activity?
    9·1 answer
  • What is an infodemic?
    10·1 answer
  • Which is an effect of short-term environmental changes?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!