Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ / Program Count prompts for, reads, echo prints, and sums a / / fixed number of integer values. The sum is printed. #include using

// Program Count prompts for, reads, echo prints, and sums a
// fixed number of integer values. The sum is printed.
#include
using namespace std;
const int LIMIT =10;
int main ()
{
int counter; // Loop-control variable
int sum; // Summing variable
int dataValue; // Input value
counter =1;
sum =0;
// Input and sum integer data values.
while (counter <= LIMIT)
{
cout << "Enter an integer value. Press return." << endl;
cin >> dataValue;
sum = sum + dataValue;
counter++;
}
cout << "Sum is "<< sum << endl;
return 0;
}
Exercise 1.
Just by reading the program count without running it, show the results that will be printed, if the
following data values are entered as prompted?
8-53-20917310
Exercise 2.
Change program Count so that the number of values to be read (LIMIT) is read from
the keyboard rather than being set as a named constant. (Dont forget to prompt for LIMIT.) Run your
program using a value of your choice for LIMIT and entering the integer data values accordingly. Show
your results in the report.
Exercise 3.
Use the program shell below to implement a program called SumDigits. When completed, program
SumDigits prompts for and reads a one-digit number, then adds the numbers from zero to the number,
inclusive, and prints the sum

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago