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
anygoal [31]
3 years ago
6

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 (size < capacity && value > 0){a[size] = value;}
1. Reads up to 3 values and places them in the array in the unused space.
2. Reads one value and places it in the remaining first unused space endlessly.
3. Reads up to 3 values and inserts them in the array in the correct position.
4. Crashes at runtime because it tries to write beyond the array.
Computers and Technology
1 answer:
lozanna [386]3 years ago
4 0

Answer:

Option 2: Reads one value and places it in the remaining first unused space endlessly.

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 (size < capacity && value > 0)
  5. {
  6.              a[size] = value;  
  7. }

The a is an array with 6 elements (Line 1). The program will prompt the user for an integer and assign it to variable <em>value </em>(Line 3).

The while loop have been defined with two conditions, 1) <em>size < capacity </em>and <em> value > 0</em>. The first condition will always be true since the size and capacity are <em>constant</em> throughout the program flow and therefore<em> size</em> will always smaller than capacity.

Hence, if user input an integer larger than 0, the while loop will infinitely place the same input value to the remaining first unused space of the array, <em>a[3]</em>.

You might be interested in
With a presentation open, you can hover your mouse pointer over a design theme on the Design tab, and PowerPoint will display th
algol [13]

Answer: Live preview

Explanation:

The live preview feature enables to display the current slide with the design theme formatting applied with the mouse pointer. This feature is also available in digital cameras where the screen can be used as viewfinder.

6 0
2 years ago
It's inventiveness uncertainty and futuristic ideas typically deals with science and technology ......what is it.
marshall27 [118]

Answer:

Necessity is the mother of invention, technology is a tool to aid invention, and science is exploratory means to new ideas and information to approach our future with preparedness.All are necessary and need to be balanced and scrutinised.

Explanation:

5 0
2 years ago
Immigrants are allowed to enter the country to work when they have a(n)
Roman55 [17]

Answer:

D. a Visa

Explanation:

4 0
2 years ago
What is the device manager in windows 8?
astraxan [27]
This is the answer hope it helps :D

5 0
3 years ago
Dell's original business strategy was to only sell custom-built computer systems directly to customers. Dell now sells to major
Keith_Richards [23]

Dell was using the cost leadership strategy but is now using differentiation leadership strategy.

#learnwithBrainly

4 0
3 years ago
Other questions:
  • Click to move a stacked object to the top of the stack?
    8·1 answer
  • What is the protocol in the web search at the bottom?
    13·1 answer
  • A ____ client locates all or most of the processing logic on the server.
    11·1 answer
  • What is the simplest way to permanently get rid of a unwanted file
    12·1 answer
  • What social impact did the gunpowder have on society?
    12·1 answer
  • Assuming 8-bit 2's complement notation, what is the result of subtracting 00001001 from 00001101?
    11·1 answer
  • design a relational database in EER for bike helmets and their reviews. a bike helmet has a name and color attributes. a bike co
    12·1 answer
  • Which term describes a visual object such as a picture, a table, or a text box?
    14·2 answers
  • Write a function called no_you_pick. no_you_pick should have two parameters. The first parameter is a dictionary where the keys
    5·1 answer
  • How do you get The gold chip on Megaman x3 snes I want To know
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!