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
HELP I WILL MARK BRAINLIEST!!! I NEED ASAP!!!
Alex777 [14]

#This is a way without a loop

friends = list(map(str,input("Enter Names: ").split()))

print(sorted(friends))

#This is a way with a loop (for&&while)

friends = list(map(str,input("Enter Names: ").split()))

cool = True

while cool:

   cool = False

   for i in range(len(friends)-1):

       if friends[i] > friends[i+1]:

           coo = friends[i]

           friends[i] = friends[i+1]

           friends[i+1] = coo

           cool = True

print(friends)

4 0
3 years ago
AirPods se están despintando al ponerlos en quitaesmalte ayudaaaa?
slega [8]

Answer:

In reality, a diluted type of acetone that dissolves plastics and coating is Nail polish removers.

Explanation:

The chemical composition of the material has permanently changed, nothing else than if you had shot it. No repair but replacement is available.

Acetone does not get along with plastics.

This classic timelapse video shows just how cheap plastic acetone is.

When it's out, I have my new AirPods Pro. I got a odd smell when I opened the box when I received it. The little one is solid and chemical. It's new, I guess, and after days it will be gone.

But after ten days of use it doesn't. And the smell remains strong. It won't go quickly, I believe.

Instead I noticed that the smell is often shaping the silicone tips.

About 8 hours a day I use this AirPods Pro. Is it possible for a long time to use this smelling tip?

Actually, I must say they are soft and work well for noise cancelation, I love this silicone tip. If the strange smell doesn't hurt. To me, that's good.

6 0
3 years ago
What was the basic invention that has evolved into the modern automobile?
anygoal [31]

Answer:

I would say Henry Ford's invention; the Ford car company, since we still have Ford cars running nowadays.

Explanation:

3 0
3 years ago
Nikki sent flyers in the mail to all houses within the city limits promoting her computer repair service what type of promotion
Jlenok [28]

Direct marketing (APEX)


6 0
3 years ago
Read 2 more answers
OSHA standards appear in the ___________ and are then broken down into ____________.
miskamm [114]
OSHA standards appear in the <span>Code of Federal Regulations (CFR) and are then broken down into Parts</span>
3 0
2 years ago
Other questions:
  • Page orientation can be either landscape or _____.
    13·1 answer
  • Qbasic program to accept 10 numbers and to find their sum. <br>​
    7·1 answer
  • Every brand of computer has its own binary language, called
    14·1 answer
  • Which of the following is a true statement?
    12·2 answers
  • Write a program that prompts the user to enter two positive integers less than 1,000,000,000 and the program outputs the sum of
    15·1 answer
  • Holi alguien sabe como cambiar el gamertag en XBox App (para iOS)?
    9·1 answer
  • Mobile apps are replacing the old__________<br><br>​
    7·2 answers
  • Write a function named findmax()that finds and displays the maximum values in a two dimensional array of integers. The array sho
    13·1 answer
  • Edhesive, 8.6 question 1
    10·1 answer
  • Which of the following items in the folder window allows users to view locations which have been visited before?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!