Add all of the numbers except for the sentinel.

Assignment Help Basic Computer Science
Reference no: EM13952973

1. The following loop is supposed to read some numbers until it reaches a sentinel (in this case -1). It is supposed to add all of the numbers except for the sentinel. If the data looks like:

12 5 30 48 -1

the program fails to do what it is purported to do. Correct it.

#include <iostream>

using namespace std;
int main()
{
int total = 0,
count = 0,
number;

do
{
cin >> number;
total = total + number;
count++;
}
while (number != -1);

cout << "The number of data read is " << count << endl;
cout << "The sum of the numbers entered is " << total
<< endl;

return 0;
}

 

Reference no: EM13952973

Questions Cloud

Create a program that models the worm''s behaviour : A worm is moving toward an apple. Each time it moves the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of ..
Difference in nicotine dependence between the proportion : Determine whether there is a significant difference in nicotine dependence between the proportion of women who are classified as professional/managerial workers in comparison to those who are classified as blue collar workers. Then compute the app..
What is the value of beta after executing the code : Suppose the input is 3. What is the value of beta after the following C++ code executes?
Resultant of the parallel coplaner force system : Determine the resultant of the parallel coplaner force system shown in fig
Add all of the numbers except for the sentinel. : The following loop is supposed to read some numbers until it reaches a sentinel (in this case -1). It is supposed to add all of the numbers except for the sentinel.
Is proportion of patients with peripheral neuropathy : The num- ber of cases of peripheral neuropathy among a control group of 35 diabetic patients was 12. Among a group of 11 patients who were taking an oral agent to prevent hyperglycemia, there were three cases of peripheral neu- ropathy. Is the pro..
Analyze the strengths and weaknesses of behaviorism : Summarize the four conditioning theories of behaviorism. Analyze the strengths and weaknesses of behaviorism, in general
Addressing appropriate business conduct : Write a minimum of a two page memo to your team addressing appropriate business conduct and etiquette when visiting Jordan and your potential clients. [I know memos are usually short, but this will be a lengthy document in order to thoroughly info..
Writing messages to a serversocket in java : the server must accept a connection before the client can communicate.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd