Program that sums a sequence of integers

Assignment Help Business Management
Reference no: EM131441456

Write a program that sums a sequence of integers. Assume that the first integer read with scanf () specifies the number of values remaining to be entered. Your program should read only one value each time scanf() is executed.

A typical input sequence might be 5 100 200 300 400 500

Use the below program template to answer each question. The program is created by answering all the questions hence, do not skip any question.

Programming Shell Template

Instructions

  1. Using the Xendesktop, open Visual Studio 2015. Create a new project and add a new .cpp file to the project.  Type the programming shell template as stated up above and continue with the following steps below.  Be sure to include comments throughout your program for readability purposes.
  2. (Housekeeping): Declare the following variables in your program using appropriate data type. When selecting a data type keep in mind the type of value you want to store, i.e., int, float, character.  Also, be sure to use conventional naming standards for all variable declarations.
    • number
    • sum

       (Hint): Since sum is going to be used for adding the value, it needs to be initialized to zero.

(Display Prompt): Write a printf() statement to ask user for the following message.

  1. (Input):Add a scanf() statement to store user input for the number of values they wish to process.
  2. (Loop structure):Now, you will write a loop structure to iterate for the number of values you want user to input.

To begin with, your loop structure will look like this - 

  1. Declare the following variable inside the loop to store the current value. Remember, the scope of this variable is limited to the loop only. It can't be referred or used outside the loop.
    • value
  2. (Output):Inside the loop, write a display prompt using a printf() statement for user to input a value using the following message.
  3. (Input):Write a scanf() statement to store the value the user keys in from the keyboard into the variable named value. 
  4. (Assignment Statement):Here comes the main part of your program. Now, you need to add this value into the variable sum. So write an assignment statement to add the input value.
  5. (Output):Outside of the loop, write a printf() statement to display the value of sum. Remember, the variable sum is declared outside of the loop so it can be referred/used anywhere within the main function. Also, to display the value stored in a variable you need to include a conversion specifier inside of the quotation marks in the printf() and the variable names within the parentheses.

Reference no: EM131441456

Questions Cloud

Current healthcare system in the united states : For this final assignment, imagine that you had the ability to change anything you wanted with regards to the current healthcare system in the United States. In a one to two page paper, outline the changes you would make to increase access, increa..
Scale organic farms fit with their broader social ideology : In the last few years is Whole Foods more about growth or its social mission? How does their support of practices such as the development of large scale organic farms fit with their broader social ideology?
Explain topic - transformer and their ratio : Write about a given topic. Topic - Transformer and their ratio. Very well presented and brief description about the topic
What value is provided by using an engineering approach : Why should an organization consider utilizing a systems analysis and design methodology when building a new system instead of building a system in any which way that seems to be fast and simple? What value is provided by using an engineering approach..
Program that sums a sequence of integers : Write a program that sums a sequence of integers. Assume that the first integer read with scanf () specifies the number of values remaining to be entered. Your program should read only one value each time scanf() is executed.
Consider three finalists for a new position : The executives of GDD are meeting to consider three finalists for a new position: Division Head of the Middle East. The winning candidate will be in a high- profile job. The effectiveness of the person in this new lead position is of utmost importanc..
What is the standard deviation of the project npv : Consolidated Oilfield plc is interested in exploring for oil near the west coast of Australia. The Australian government is prepared to grant an exploration license to the company for a five-year period for a fee of £250,000 per annum.
Write about green chemistry : Topic - Green Chemistry. A PowerPoint presentation Very well presented giving all necessary information about the topic
Linear relationships between body measurements : In this section, we saw a relationship between armspans and height. There are other linear relationships between body measurements. One such relationship is between the circumference of a wrist and the circumference of a neck.

Reviews

Write a Review

Business Management Questions & Answers

  Transformational versus transactional leadership

In your assignment, compare and contrast transformational leadership and transactional leadership. With which leadership style do you most identify? Why?

  Eastman kodaks key stakeholdersfind and describe eastman

eastman kodaks key stakeholdersfind and describe eastman kodaks key stakeholders. what is their influence on strategy?

  Do you agree that businesses should be liable for injuries

read malorney v. bampl motor freigh t inc. in section 21.2 of your textbook google online. discuss what duty or duties

  Explain for each named defendant whether the court is like

In this case, list all the defendant(s) you would advise Sang to name in the lawsuit and explain why each defendant should be named? Explain, for each named defendant, whether the court is likely to find out the defendant liable and explain why/e..

  Assessing the importance of goals

what options do lower level employees have to voice their concerns or disagreement without appearing to be non-compliant, or worse, defiant?

  Why it is important to analyze stakeholder interests

Who are stakeholders in a negotiation? Why it is important to analyze stakeholder interests? How do you take these interests and incorporate them into a negotiating strategy?

  Money between measuring and reporting these two dimensions

Outcomes are ultimately what we want to achieve in healthcare. But process is what we can act to improve. If you had a fixed budget, how would you allocate your money between measuring and reporting these two dimensions?

  Explain adoption process

Explain how an understanding of the adoption process would help develop a promotion blend for digital tape recorder, a new consumer electronics product which produces high-quality recordings. Explain why you might change the promotion blend during..

  Social expectations of business

1. List and describe the consumer rights that have become social expectations of business. Why have some of these rights been formalized through legislation? Should these rights be considered ethical standards?

  Calculating design and effective capacity utilizationa

calculating design and effective capacity utilizationa manufacturer of printed circuit boards has a design capacity of

  Explore corporate websites that have a recruitment area

Explore 4 to 6 corporate websites that have a recruitment area as well as note their major features and strengths and weaknesses. Create a table that contains

  Strategy the company uses to manage the exposure

Discuss the strategy the company uses to manage the exposure. If your example does not provide a strategy, recommend one.

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