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
How would I view the ruler on my document if it was not visible
svlad2 [7]
For MS Word 2010 and higher
Go to "View" and find checkbox "Ruler"
8 0
3 years ago
Most manual-transmission vehicles use a _______ to gauge engine speed in RPMs. A. variable valve timer B. tachometer C. torque i
gavmur [86]
I believe the answer is b. tachometer

5 0
3 years ago
When a program terminates because a thrown exception is not handled, the program:
castortr0y [4]

Answer:

Option (e)

Explanation:

Option (e) is the answer. It indicates the exception thrown and displays it. It also indicates the place where the exception was thrown ( at what line of the code the exception was thrown )

Option (a) is false as the program which was terminated because of an exception which was not handled doesn't starts automatically.

Option (b) is false as it doesn't opens a dialogue box about running the program another time or anything. It just terminates because of the unhandled exception.

Option (c) is false as it doesn't saves all the output to a disk file called the "runStackTrace.txt".

Option (d) is false as it doesn't open a dialogue box. The program terminates because of the unhandled exception.

4 0
2 years ago
Write a small program basic c++, that defines a negative integer (between ‐1 and ‐255), converts it to a positive value and then
ANEK [815]

Answer:

#include <iostream>

using namespace std;

int main() {

int a=-156;//negative integer between -1 and -255.

a*=-1;//multiplying a to -1 so that it can become positive.

cout<<a;//printing a.

return 0;

}

Explanation:

The above written program is in C++ and in the program an integer a is defined with a negative value in the program it is -156.Then to convert it to positive integer we have to multiply a to -1 after that printing the value of a on the screen.

4 0
2 years ago
Which type of data is generally stored in different file formats, such as text files, spreadsheets, and so on?
zepelin [54]

Answer:

Plain text storage (eg, CSV, TSV files)

Sequence Files.

Avro.

Parquet.

3 0
2 years ago
Read 2 more answers
Other questions:
  • What test is most similar to binary​
    9·1 answer
  • Legal functions are the most important area of IG impact. Under the FRCP amendments, corporations must proactively manage the e-
    9·1 answer
  • Whoever answers first gets lots of points
    14·2 answers
  • Calculate the ERA
    6·1 answer
  • We cannot imagine a life without the Internet. Imagine that you had to live without being connected to the Internet. Discuss the
    9·1 answer
  • True false.
    10·2 answers
  • wooooooooo helll yeaaa made it to ACE baby now road to whatever next, lil present imma be doing You tube soon soo ideas will be
    7·2 answers
  • How many hours do you spend on the Internet per day?
    11·2 answers
  • If two devices simultaneously transmit data on an Ethernet network and a collision occurs, what does each station do in an attem
    8·1 answer
  • Which website offers guidance on putting together a checklist to provide guidance on configuring and hardening operating systems
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!