© Radek Vystavěl 2017

Radek Vystavěl, C# Programming for Absolute Beginners, https://doi.org/10.1007/978-1-4842-3318-4_24

24. Accumulating Intermediate Results

Radek Vystavěl

(1)Ondřjov, Czech Republic

In this chapter, you will study the important case of using loops to process large sets of data. You will often use a loop to go through a large amount of data to accumulate (aggregate) some intermediate result, which becomes the final result after the loop terminates.

Sum of the Entered Numbers

A typical task in this category is summing a lot of values.

Task

Say the user is entering numbers, with the last one being 0. In other words, users indicate they are finished by entering 0. The program then displays the sum of all the entered numbers (see ...

Get C# Programming for Absolute Beginners now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.