answer.
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
elixir [45]
2 years ago
15

Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value is consi

dered a CONSECUTIVE DUPLICATE. In this example, there are three such consecutive duplicates: the 2nd and 3rd 5s and the second 6. Note that the last 3 is not a consecutive duplicate because it was preceded by a 7.
Write some code that uses a loop to read such a sequence of non-negative integers , terminated by a negative number. When the code exits the loop it should print the number of consecutive duplicates encountered. In the above case, that value would be 3.
Computers and Technology
1 answer:
iris [78.8K]2 years ago
5 0

Answer:

Following is the source code required:

int entry_1 ,entry_2 = -1, consecutive_duplicates = 0;

do {

cin >> entry_1;

if ( entry_2 == -1)

{

entry_2 = entry_1;

}else

{

if ( entry_2  == entry_1 )

consecutive_duplicates++;

else

entry_2  = entry_1;

}

}

while(entry_1 > 0 );

cout << consecutive_duplicates;

Explanation:

Following is the explanation for given code:

  • 3 integers are declared as entry_1, entry_2  and consecutive_duplicates.
  • entry_2 = -1 (it will tell that the integers are non-zero)
  • user will enter the value for entry_1
  • The loop will be applied which will check for the value of entry_2. If entry_2 = -1, the value of entry_1 will be stored in entry_2 else it the value of entry_2 is already equal to entry_1, the integer consecutive_duplicate in increased by one.
  • Now the value of entry_1 is stored in entry_2 , so that next entity might be checked.
  • In the end, while the entry_1 is greater than zero (unless the last (negative)element of array is reached), print the integer consecutive_duplicates.

i hope it will help you!

You might be interested in
Carrie works on a help desk and is assigned a ticket that was automatically generated by a server because of an error. The error
mixas84 [53]

The windows tool of weapon of choice that Carrie will use to troubleshoot the server is Powershell. All those GUI consoles built by Microsoft for Windows, by default, execute Powershell commands behind the scenes. Every possible thing that Carrie can do with the physical server can easily be accessible through Powershell's command line interface

Further Explanation

I would honestly say that there are a few available tools that Carrie can use, but the best tool is the inbuilt Windows Powershell. As Powershell continues to extend its purpose and usefulness, Microsoft, on the other hand, continues to use Powershell's capability to develop more cmdlets for products like Windows Servers.

Everything that can be done in a GUI environment can be done in Powershell. Carrie should be able to use Powershell to run things more efficiently from the command line without stepping a foot on the physical server. She will only need to access the server from her desk remotely, run a few commands, and that is it. Powershell command line is so powerful; it carries with it every troubleshooting pack that you can think about.

Learn More

brainly.com/question/10178399

brainly.com/question/10338479

#LearnWithBrainly

5 0
2 years ago
Read 2 more answers
JAVA
barxatty [35]

Answer:

Answer is in the provided screenshot! This was a lot of fun to make!

Explanation:

We need to create a new Array which has to be the size of amount * original - as we now that we are going to have that many elements. Then we just iterate through all the values of the new array and set them equal to each of the elements in order.

Ignore the code in my main function, this was to print to the terminal the working code - as you can see from the output at the bottom!

5 0
2 years ago
In the game Singularity, broken objects can be restored to their original condition by reversing time. This is an example of whi
Zolol [24]

Solution:

In the game Singularity, broken objects can be restored to their original condition by reversing time. This is an example of which time element of player adjustment.

Thus the required answer is player adjusted.

6 0
2 years ago
Read 2 more answers
What will the output of this program be when it is executed? def test_function( length, width, height): print ("the area of the
erastova [34]

Answer: stuff

Explanation:

6 0
2 years ago
In this problem we consider sending real-time voice from Host A to Host B over a packet-switched network (VoIP). Host A converts
Minchanka [31]

Answer:

<u>The total time elapsed from the time a bit is created (from the original analog signal at Host A) until the bit is decoded (as part of the analog signal at Host B is </u><u>25.11 ms</u>

Explanation:

Host A first converts the analog signal to a digital 64kbps stream and then groups it into 56-byte packets. The time taken for this can be calculated as:

time taken 1= \frac{Packet Size in Bits}{Bit Rate}

                 = (56 x 8) bits / 64 x 10³ bits/s

                 = 7 x 10⁻³s

time taken 1= 7 ms

The transmission rate of the packet from Host A to Host B is 4 Mbps. The time taken to transfer the packets can be calculated as:

time taken 2= (56 x 8) bits / 4 x 10⁶ bits/s

                    = 1.12 x 10⁻⁴ s

time taken 2= 112 μs

The propagation delay is 18 ms.

To calculate the total time elapsed, we need to add up all the time taken at each individual stage.

<u />Time_{total}<u> = Time taken 1 + Time taken 2 + Propagation Delay</u>

                 = 7 ms + 112 μs + 18 ms

                 = 0.025112 s

Time_{total} = 25.11 ms

5 0
2 years ago
Other questions:
  • Carefully choosing from a set of alternatives to accomplish an objective is known as? A. Independence B. Decision making C. Netw
    9·2 answers
  • Which is true of case-based reasoning (CBR)?
    6·1 answer
  • FTP requires confirmation that a file was successfully transmitted to a client, but it has no built-in mechanism to track this i
    5·1 answer
  • You are on vacation and want to see where all the restaurants and trendy shops are in relation to your hotel. You remember there
    15·1 answer
  • Write the definition of a function power_to, which receives two parameters. The first is a float and the second is an integer. T
    5·1 answer
  • Ken Olson, president of Digital Equipment Corp. in the late 1970's, Thomas J. Watson, chairman of IBM in the early 1940's, and T
    6·1 answer
  • Company A is setting up a network of mostly Windows machines. Which networking file system protocol would you recommend for maxi
    5·1 answer
  • What is an input to the Program Increment Planning process that highlights how Product Management plans to accomplish the Vision
    15·1 answer
  • #Write a function called fancy_find. fancy_find should have #two parameters: search_within and search_for. # #fancy_find should
    9·1 answer
  • Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!