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
elixir [45]
4 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]4 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
If your computer won't connect to the internet, which of these is most likely to be the problem?
Setler79 [48]

Answer: just like rtyguj said, RAM, ROM, and O USB are all built into your computer so it would be onic

8 0
3 years ago
The best way to find out the average salary in your company is to perform a technique, known as Advanced Calibrated Sampling (AC
Setler [38]

Answer:

Agree

Explanation:

The best way to find out the average salary in your company is to perform a technique, known as Advanced Calibrated Sampling (ACS).

7 0
3 years ago
Usted repetir la pregunta?<br>O A. Es<br>B. Puede<br>C. Puedes<br>O D. Está​
puteri [66]

Answer:

I believe the answer is B. Puede

5 0
3 years ago
Read 2 more answers
Chuyến đỗi biểu số giữa các hệ đếm <br> 011011 =?
aleksley [76]
If u need the answer in decimal binary system then 10101100000011 is the answer .
8 0
2 years ago
I NEED HELP
lilavasa [31]
Well, if your asking about all types of meaning for play, I hope this works. Verb version: Play meaning 1: engage in activity for enjoyment and recreation rather than a serious or practical purpose. Meaning 2: take part in (a sport). Meaning 3: represent (a character) in a theatrical performance or a film. Meaning 4: perform on (a musical instrument). Noun version: meaning 1 of play: activity engaged in for enjoyment and recreation, especially by children. Meaning 2: the conducting of an athletic match or contest. Meaning 3: a dramatic work for the stage or to be broadcast. Meaning 4: the space in or through which a mechanism can or does move. Hope this helped!
8 0
4 years ago
Other questions:
  • You can deselect multiple selected sheets beginning with the sheet1 tab by pressing the ____ key and clicking the sheet1 tab.
    15·1 answer
  • The wireless spectrum, as defined by the fcc, spans between which two frequencies?​
    7·1 answer
  • Which type of memory helps in reading as well as writing data? With the help of , a computer can read as well as write or modify
    11·3 answers
  • Which is the most accurate description of which cell contains a nucleus
    5·1 answer
  • History timeline: who developed what elements first Windows OS and Apple OS?
    13·2 answers
  • PowerPoint SAM Capstone Project 1 can PLEASE someone do it for me I have some directions like steps and you just have to do it i
    10·2 answers
  • If String str = "Computer Science";, then what is the value of str.substring(10);? ​
    6·1 answer
  • How many 60 KB jpeg files can be stored on a 2 MB folder in your hard drive?​
    7·1 answer
  • The temperature at 8 AM was 44°F and at noon it was 64°F. what was the percent of change from 8 AM to noon?
    11·1 answer
  • A toolbar of round buttons that appear when you move the mouse when in Slide Show view id called ____________.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!