subject

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;
size++;
value = cin. nextint();
}

1. reads one value and places it in the remaining first unused space endlessly.
2. crashes at runtime because it tries to write beyond the array.
3. reads up to 3 values and places them in the array in the unused space.
4. reads up to 3 values and inserts them in the array in the correct position.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:30, klk597703
Aprovides legal protection for something an individual has created
Answers: 1
image
Computers and Technology, 22.06.2019 04:00, yolo1430
Acetylene is a gas which burns rapidly on its own, and is considered highly explosive. a) true b) false
Answers: 2
image
Computers and Technology, 22.06.2019 08:10, Bearboy5957
Ihave a music player on my phone. i can buy songs, add them to playlists and play them. obviously it would be redundant to store each song in each playlist; each playlist is just a list of pointers to the songs. for this lab you will simulate this behavior. your program will need to have options to: add songs to the system library (you will store the text of the first line of the song, rather than the audio) add playlists add songs to a playlist list playlists play a playlist list all of the songs in the library with a count of how many times each song has been played remove a song from a playlist remove a playlist remove a song from the library (and thus from all playlists that contain it) note that we will not be checking many error cases. in real programming this would be bad, you should usually try to recognize and respond to as many types of errors as you can. in the context of class we are trying to acquaint you with as many concepts as possible, so for the sake of educational efficiency we will not be checking most errors in this lab, you may assume that your user provides correct input. you may add all appropriate error testing if you wish, but we will not be testing for it.
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, abbygriffin2009
Martha is a healer, a healthcare provider, and an experienced nurse. she wants to share her daily experiences, as well as her 12 years of work knowledge, with people who may be interested in health and healing. which mode of internet communication can martha use?
Answers: 3
You know the right answer?
Consider the partially-filled array named a. what does the following loop do? (cin is a scanner obj...

Questions in other subjects: