8.5k views
1 vote
The program requests the user to enter a sequence of numbers and displays the accumulation sum per entry. (set the MAX_ENTRY = 5, and initialize the total to zero before starting)

Result:
This program calculates the sum of 5 numbers as you enter them
Enter number 0: 3
0 + 3 = 3
Enter number 1: 4
3 + 4 = 7
Enter number 2: 5
7 + 5 = 12
Enter number 3: 3
12 + 3 = 15
Enter number 4: 5
15 + 5 = 20
Done

User JREN
by
7.9k points

1 Answer

6 votes

Final answer:

The exercise involves programming a sequence of number entries, with the program displaying an updated accumulation sum after each input. The operation uses the associative property of addition and sets MAX_ENTRY to 5 with the initial total set to zero.

Step-by-step explanation:

The question pertains to a programming exercise where the user is asked to enter a sequence of numbers, and the program calculates and displays the running total or accumulation sum after each entry. The program in question is designed to accept a maximum of five entries, setting the MAX_ENTRY constant to 5. Before the user begins entering numbers, the total is initialized to zero. As the user enters each number, the program adds it to the ongoing total and displays the new sum to the user.

Commulative addition in this context is irrespective of the order in which the numbers are added. Just like with ordinary numbers, the associative property of addition means that adding 3 and 2 to get 5 is the same as adding 2 and 3 to get 5. This concept underscores the program's ability to add numbers in the sequence they are entered without affecting the final summation.

User Johnnieb
by
8.2k points