In a past lesson we counted the occurrences of each digit in $\pi$. This lesson
is a bit of a repeat of that lesson, but does an analysis using arrays and the creation of a professional
looking histogram chart.

In this case, each digit of $\pi$ is read from the variable `bigpi`

. Each digit is used as an index
into an array called `hist`

that keeps track of the number of times a given digit occurs in `bigpi`

.
Another array called `digit`

is used to seed the horizontal axis of the histogram, as it is loaded
with the numbers from 0 to 9, which are the possible digits in $\pi$.

`digit[i] =`

so `digit`

will hold the numbers from 0 to 9. Fix the `hist[i]= `

line
so that all counts start at zero. Lastly, fix the `hist[d] =`

line so that it is increased by
one inside of the `if`

statement.
Type your code here:

See your results here:

This code will not run! You have to make 3 fixes:

- What will you put in for
`digit[i] =`

line so that the $i^{th}$ element of array`digit`

contains the $i^{th}$ possible digit of $\pi$ running from $0$ to $9$? - What will you put in for the
`hist[i]`

line to initially set all histogram counts equal to zero? - For the line inside of the
`if`

statement, the variable`d`

contains the current digit of $\pi$ found in`bigpi`

(i.e. a number from 0 to 9), what how will you fix the`hist[d] =`

line so that`hist[d]`

is increased by one relative to its currently held count? Hint: It's related to what's in this lesson. Dismiss.

Does your code work? Want to run it on your iPhone?

Here's your code:

- Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.
- Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into
this page
- Then click the "Use on iPhone" button that you'll see.