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
vodka [1.7K]
4 years ago
10

What does a contain after the following code runs?int[] a = {1, 3, 7, 0, 0, 0};int size = 3, capacity = 6, value = 5;int pos = 0

;for (pos = 0; pos < size; pos++)if (a[pos] < value) break;for (int j = size; j > pos; j--)a[j] = a[j - 1];a[pos] = value;size++;
Computers and Technology
1 answer:
Lady bird [3.3K]4 years ago
3 0

Answer:

a={5,1, 3,7, 0, 0}

Explanation:

when the code runs,

a={1, 3, 7, 0, 0, 0} , size=3, capacity=6 ,value=5,pos=0.

When loop starts pos is zero for pos 0,1 if conditon is true and loop breaks and moves to next loop.

On first iteration pos is 0 and j is 3. it moves element at 3rd index to 2.

On second iteration pos is 0 and j is 2. it moves element at 2nd index to 1.

On third iteration pos is 0 and j is 1. it moves element at 1st index to 0.

On fourth iteration pos is 0 and j is 0.Hence the condition for loop is false and the code inside does not run. This behavior  is followed until loop completes all iterations

As pos is not changing after each iteration 0th index is 5.

You might be interested in
8.11 LAB: Count characters - functions Write a program whose input is a character and a string, and whose output indicates the n
Shkiper50 [21]

Answer:

#include<iostream>

using namespace std;

int CountCharacters(char userChar, const string inputstr){

   int k = 0;

   int iter = 0;

   for (iter = 0; iter < inputstr.size(); iter++){

       if (inputstr[iter] ==  userChar){

           ++k;        }}

   return k;}

int main(){

   string str;

   char userChar[1];

   cout<<"Char: ";    cin>>userChar;

   cin.ignore();

   cout<<"String: ";   getline(cin, str);

   cout<<CountCharacters(userChar[0],str);

   return 0;}

Explanation:

Written in C++:

The function is defined here:

int CountCharacters(char userChar, const string inputstr){

This initializes a count variable k to 0

   int k = 0;

This initializes an iterating variable iter to 0

   int iter = 0;

This iterates through the characters of the string being passed to the function

   for (iter = 0; iter < inputstr.size(); iter++){

This checks for matching characters

       if (inputstr[iter] ==  userChar){

If found,  k is incremented by 1

           ++k;        }}

This returns the total count

   return k;}

The main begins here

int main(){

This declares a string variable

   string str;

This declares a character variable

   char userChar[1];

This gets input for the character variable

   cout<<"Char: ";    cin>>userChar;

This lets the user get another input

   cin.ignore();

This gets input for the string variable

   cout<<"String: ";   getline(cin, str);

This calls the function and return the count of character in the string

   cout<<CountCharacters(userChar[0],str);

6 0
3 years ago
How to play Drinkopoly game?
professor190 [17]
Answer:
Never heard of that lol
3 0
3 years ago
The Occupational Outlook Handbook is published by the Bureau of Labor Statistics.
nika2105 [10]
HEY THEIR

The correct answer is A. true.

It was written in 1948 by the bureau of Labor statistics .

HOPE IT HELPS YOU
7 0
3 years ago
1. It is a requirement to install a routing protocol that monitors the network for routers that have changed their link state. T
Nady [450]

Answer:

1. Open Shortest Path First (OSPF)

2. Border Gateway Protocol (BGP)

3. Routing and Remote Access Service (RRAS)

4. Frame relay

5. Synchronous

6. Virtual

7. Committed Information Rate (CIR)

8. Integrated Services Digital Network (ISDN)

9. Asynchronous Transfer Mode (ATM)

10. Basic Rate Interface (BRI).

8 0
4 years ago
Wireless internet is an example of telecommunications.
lawyer [7]
Anything is telecommunication if it has a <span>transmitter</span> and receiver. If you're a Host, then you're hosting (Transmitting) a connection. If you have a router as a customer or service, then you're receiving their signal (transmitting). You're the receiver. 
7 0
3 years ago
Other questions:
  • There is a colony of 8 cells arranged in a straight line where each day every cell competes with its adjacent cells(neighbour).
    11·1 answer
  • A report formatted where the page is taller than it is wide is formatted in ____.
    12·1 answer
  • An important piece of a project is past due date.
    9·2 answers
  • Whats the relationship between the CPU and motherboard
    6·1 answer
  • ¿Es especial que mi cumpleaños sea el día de San Valentín?<br><br> si o no
    11·2 answers
  • What was the first video game ever invented
    11·2 answers
  • PLZ HELP! ANSWER (WITH CORRECT ANSWER AND EXPLANATION THAT ACTUALLY IS CORRECT) GETS BRAINLIEST!
    13·1 answer
  • Please help meeee , you will get 20 points
    9·2 answers
  • The email_list function receives a dictionary, which contains domain names as keys, and a list of users as values. Fill in the b
    14·1 answer
  • Identify the names of the following:<br><br>Please help me.​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!