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
Will mark Brainliest!! What is the best hard disk compacity? Why?
choli [55]

Answer:

The SeaGate FireCuda is the best hybrid hard drive.

Explanation:

The SeaGate FireCuda is the best hybrid hard drive on the market. It can fit up to 2TB of data, and then its 8GB of solid state cache storage learns which data you use most, so that you can access it quickly. That speed boost is even sweeter when you consider that this drive spins at 7,200rpm.

3 0
2 years ago
which tag does not display the text in the browser window and makes the sources code mode readable ?​
maxonik [38]

Answer:

HTML comments are not displayed in the browser, but they can help document ... You can add comments to your HTML source by using the following syntax: <! ... you can comment out HTML lines of code, one at a time, to search for errors: ... Use the HTML comment tag to make a comment out of the "This is a comment" text.

Explanation:

Gimme brainliest right now.

3 0
3 years ago
True or false: Quality score is an algorithm that scores each of your search ads on spelling and grammar.
andrew11 [14]
True or false: Quality score is an algorithm that scores each of your search ads on spelling and grammar.

Answer: False

I think sorry
4 0
2 years ago
If the speakers are not working on a laptop, what could be the problem besides the speakers?
Elena-2011 [213]

Answer:

Sound card

Explanation:

In computer or laptop music or sound files are stored in digital form. Sound card is the the device that is used to convert the digital form of music into analog to produce the signal that is compatible with speaker or microphone.

If the speakers are not working on the laptop, means there is no sound produced on speakers. It means that sound card is not working properly.

8 0
3 years ago
Jennifer has written a short story for children. What should be her last step before she submits the story for publication?
SSSSS [86.1K]

Answer:

What is the choice of being answer c?

6 0
4 years ago
Other questions:
  • What term refers to a piece of software that interfaces with the hardware on your computer?
    10·2 answers
  • I can't wait until school ends
    9·2 answers
  • Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr
    7·1 answer
  • How can volunteering yo help plan fundraiser for your team or club be a way to develop your strengths?
    13·1 answer
  • How to code on python
    8·2 answers
  • The editing of digital photos us about the same level of difficulty as editing an analog photo
    12·1 answer
  • Whats a field in databases?
    5·1 answer
  • Which of the following tools helps ensure your document will open in older versions of word
    13·1 answer
  • Which is the best choice to explain why a human resource manager is so
    5·1 answer
  • Please answer quickly :S
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!