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
cestrela7 [59]
2 years ago
14

c++ 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 c

onsidered 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
2 answers:
Ludmilka [50]2 years ago
8 0

Answer:

int firstNumber,secondNumber = -1, duplicates = 0;

do {

   cin >> firstNumber;

   if ( secondNumber == -1) {

       secondNumber = firstNumber;

   }else {

       if ( secondNumber == firstNumber )

           duplicates++;

       else

           secondNumber = firstNumber;

   }

} while(firstNumber > 0 );

 

cout << duplicates;

Explanation:

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. We test the following on a C++ platform.

int firstNumber,secondNumber = -1, duplicates = 0;

do {

   cin >> firstNumber;

   if ( secondNumber == -1) {

       secondNumber = firstNumber;

   }else {

       if ( secondNumber == firstNumber )

           duplicates++;

       else

           secondNumber = firstNumber;

   }

} while(firstNumber > 0 );

 

cout << duplicates;

Ksivusya [100]2 years ago
4 0

<u>Answer:</u>

<em>int fNumber,scndNumber = -1,  </em>

<em>dup = 0; </em>

<em>do { </em>

<em>cin >> fNumber; </em>

<em>if ( scndNumber == -1) { </em>

<em>scndNumber = fNumber; </em>

<em>} </em>

<em>else { </em>

<em>if ( scndNumber == fNumber ) </em>

<em>duplicates++; </em>

<em>else </em>

<em>scndNumber = fNumber; </em>

<em>} </em>

<em>} while(fNumber > 0 );  </em>

<em>cout << dup; </em>

<u>Explanation:</u>

Here three variables are declared to hold the first number which is used obtain all the inputs given by the user, second number to hold the value of <em>last encountered number and “dup” variable to count the number of duplicate values.</em>

<em>“Do-while”</em> loop help us to get the input check whether it is same as previous input if yes then it <em>adds to the duplicate</em> value otherwise the new previous value if stored.

You might be interested in
This is used to copy information from cell to cell in the spread sheet
Kryger [21]

Answer:

D. Fill handle

Explanation:

Required

Which can be used to copy from cell to cell

(a); Means the current cell being selected in the spreadsheet program

(b): Used to fit all columns in the spreadsheet program. Usually, the columns are fitted based on their width.

(c): The vertical and horizontal lines that separate cells.

(d): This is used to copy from one cell to another, especially adjacent cells.

5 0
3 years ago
What is required to control access to the file system using file and folder permissions on a windows based computer?
Elis [28]
NFTS-formatted partition.
5 0
3 years ago
Which should be addressed by stakeholders when reviewing the problem statement? Select all that apply. All possible outcomes hav
kumpel [21]

Answer:

  • The problem as they see it has been addressed
  • The solution proposed will meet their needs
  • The needs of their colleagues are being met
  • All issues and constraints have been identified

Explanation:

The stakeholders in a project or business involves every human resource of the business/project that is essential to the successful completion of the business/project at hand.

The factors to be addressed by stakeholders when reviewing a problem statement is very important for the success of the project hence : the problem as seen in the problem statement has to be addressed, the solution been proposed to solve every problem identified should meet the needs of every stakeholder, also every stakeholder in a project has to be carried along hence the need of every stakeholder has to be considered as well.

7 0
2 years ago
Which one is not an operating system?1.mac 2.Microsoft office3.Iso.3.Android
quester [9]
It's either microsoft or office. Based on research I would say office.

I really hope this helps you! :-)
6 0
2 years ago
How to shutdown a computer by step by step​
Reptile [31]

<u><em> </em></u>Answer:

1) Press Ctrl + Alt + Del

2) Click the power button in the bottom-right corner of the screen.

3) From the desktop, press Alt + F4 to get the Shut Down Windows screen.

and that's how to shut down your computer

<u><em></em></u>

<u><em>Please mark as brainliest if answer is right</em></u>

Have a great day, be safe and healthy  

Thank u  

XD  

7 0
2 years ago
Read 2 more answers
Other questions:
  • In the following statement:
    12·1 answer
  • A _________ is the broadcast of various types of media over the web.
    10·2 answers
  • __________ has become a widely accepted evaluation standard for training and education related to the security of information sy
    5·1 answer
  • "_____ devices improve memory by encoding items in a special way."
    13·1 answer
  • Discuss the importance of employee security awareness training. What innovative ways should company’s implement security trainin
    14·1 answer
  • What is required to contain warnings, after several studies that have shown that they are a suffocation risk?
    15·2 answers
  • 30 points) Suppose you are given a string containing only the characters ( and ). In this problem, you will write a function to
    14·1 answer
  • Claire writes a letter to her grandmother, in which she describes an amusement park she visited last week. She adds pictures of
    13·1 answer
  • Why can it be helpful to perform mathematical calculations using programming? Choose the best answer.
    11·1 answer
  • Define the term loop rule.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!