ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 10 Weeks Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 04 May 2017 My Price 9.00

Write a program that sums a sequence of integers

I was making some errors and need help?

 

Problem Statement

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

#include <stdio.h>

int main (void)

{

               //YOUT CODE GOES HERE....

                return 0;

}

Instructions

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.

  1. (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.

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

Enter the number of values to be processed:

 

 

3. (Input): Add a scanf() statement to store user input for the number of values they wish to process.

4. (Loop structure): Now, you will write a loop structure to iterate for the number of values you want user to input.

for (int i =1; i<=number; i++

{

                       //code to enter a value and total the values

}

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

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

5. (Output): Inside the loop, write a display prompt using a printf() statement for user to input a value using the following message.

Enter a value

 

 

 

6. (Input): Write a scanf() statement to store the value the user keys in from the keyboard into the variable named value.

7. (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.

sum = sum+value;

8. (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.

9. (Output Screen) When you execute the program, it should be similar to the following:

Attachments:

Answers

(11)
Status NEW Posted 04 May 2017 01:05 AM My Price 9.00

-----------

Attachments

file 1493862927-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)