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

  The product demand so crucial for a firm

Why is knowing (or estimating) the product demand so crucial for a firm?  In your response, include an example of a business that has suffered from poorly estimating the demand of its products.  Evaluate how or why the business made such a mistake.

  Game changing technology

The Internet is considered a ‘game changing' technology. Discuss at least three reasons why this is true.

  Write an instruction sequence to swap the upper

Write an instruction sequence to swap the upper four bits and the lower four bits of accumulator A [swap bit 7 with bit 3, bit 6 with bit 2, and so on]

  What is the formula for cost per life saved

What is the formula for cost per life saved on this following case study: Diagnosed arvophillia cases in total population Severe arvophillia among diagnosed cases

  How can users help analysts create better erds?

How can users help analysts create better ERDs?

  Paper about the inheritance structures of galaga.

Identify the parent and child classes and describe what each class has for events and data. If you are unfamiliar with Galaga, do a web search on the topic to find some resources.

  Secure computing

Secure Computing

  Distinguish online learning with classroom learning

Write the exploratory essay in which you distinguish online learning with classroom (on-ground) learning. Your estimation may incorporate preparation time.

  Explaining formal risk assessment of desktop systems

As apart of a formal risk assessment of desktop systems in small accounting firm with limited IT Support, you have identified asset "integrity of customer and financial data files on desktop systems" and threat.

  Write a function oriented program to compute the compound

How is pass by reference implemented in the program. Write a function oriented program to compute the compound interest for the sum invested for any number of years using the concept of pass by value.

  You may have observed such a situation before a highly

you may have observed such a situation before a highly publicized and outrageous crime has taken place and the suspect

  Create a worksheet that computes membership costs

Create a worksheet that calculates membership costs for Buff and Tuff Gym. You will create functions that determine costs based on a condition, lookup membership rates and fees, and calculate monthly payments. You will also create functions that ..

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