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]
3 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]3 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]3 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
A strategic business unit​ (SBU) of a major corporation has high market share in its​ industry, but the growth rate of the indus
VLD [36.1K]

Answer:

Cash cow

Explanation:

A cash cow is seen or made reference to as that part of a business, investment, or product that provides a steady income or profit.

Basically a cash cow is a business unit, product line, or investment that has a return on assets (ROA) greater than the market growth rate. This is expressed with an Idiom to mean that it produces "milk" that is profit long after the cost of the investment has been recouped.

The strategic business unit of this organization having high market share in its​ industry, but the growth rate of the industry is expected to be stagnant over the long run is simply yielding steady profit for the corporation through its high market value and this will continue for longer because it has to be at that high rate for a long period of time.

The SBU can be categorised as acting as the cash cow for that corporation.

6 0
3 years ago
Read 2 more answers
What is the memory of a computer called
Nataliya [291]
It is called Ram in another term for memory :)
6 0
3 years ago
Read 2 more answers
Write the logical Expression and Draw the Truth table for the <br> following questions
Alja [10]

The logical expressions are

  • (X NOR Y ) OR Z ⇒ (\bar X  \bar + \bar Y) + Z
  • (A NAND B) AND NOT C ⇒ (\bar A \bar \cdot\bar B) \cdot \bar C

<h3>How to determine the logical expressions?</h3>

<u>Logical expression 1</u>

X and Y are linked by the NOR gate.

So, we have:

X NOR Y

The X NOR Y is linked to Z by the OR gate.

So, we have:

(X NOR Y) OR Z

Hence, the logical expression is (X NOR Y ) OR Z ⇒ (\bar X  \bar + \bar Y) + Z

<u>Logical expression 2</u>

A and B are linked by the NAND gate.

So, we have:

A NAND B

The A NAND B is linked to C by the AND gate.

So, we have:

(A NAND B) AND C

Hence, the logical expression is (A NAND B) AND NOT C ⇒ (\bar A \bar \cdot\bar B) \cdot \bar C

See attachment for the truth tables

Read more about truth tables at:

brainly.com/question/27989881

#SPJ1

6 0
2 years ago
Based on the information in the table, which of the following tasks is likely to take the longest amount of time when scaled up
kakasveta [241]

Answer:

Task A

Explanation:

8 0
3 years ago
Select the correct answer. Marie uses a browser to visit a blog. How is the blog uniquely identified? A. web page B. website C.
damaskus [11]

Answer:

I belive the answer is E

Explanation:

8 0
2 years ago
Other questions:
  • Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
    9·2 answers
  • What is the difference between a learner’s license and an operator’s license?
    5·1 answer
  • The dlci field in the frame relay header is _________ bits long.
    14·1 answer
  • Whats the best app for cheaters​
    9·1 answer
  • Insert a row above the selected row (in between row 1 and row 2).
    15·2 answers
  • Short Essay on the history of Computer​
    6·2 answers
  • An electronic storage file where information is kept is called a cpu. true false
    11·1 answer
  • Light the<br> Spark hop<br> Answer if ur a baddie;)))
    9·2 answers
  • What should be entered to make the loop print
    6·1 answer
  • Cara is cleaning her computer when she notices a loose cable connecting to her printer. Which two ports would the cable most lik
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!