# Math Help - C++ programming.

1. ## Re: C++ programming.

ok as you say

2. ## Re: C++ programming.

If you know arrays, a more elegant way to find totals is as follows.

Code:
int x;
// Reserve 7 numbers: totals[0], ..., totals[6]; the first is not used
// Initialize all numbers to 0
int totals[7] = {0};

for (int i = 0; i < 20; i++) {
cout << "Please input the result of the " << i << "th toss: ";
cin >> x;
totals[x]++; // Increase the xth number by 1
}
It is recommended to place code between the [code] ... [/code] tags. The toolbar button with # inserts these tags around the selected text. Then spaces and formatting are preserved.

Page 2 of 2 First 12