Skip to main content
added 107 characters in body
Source Link
Abtin Forouzandeh
  • 5.9k
  • 4
  • 27
  • 28

It is creating a histogram of the characters 0-9. It subtracts '0' which"c- '0'" turns the values in 0-9value from getchar() into an integer, which acts as the index for the array reference,. This index corresponds to the numbers 0-9. It then it increments that location in the array location. Each position inThus, once it has completed running, the array corresponds to a characterconsists of the repetitions for the characters 0-9.

So 0123456789 should createresult in an array of all ones. 0123333 should createresult in an array starting with the values 11141114000000.

It is creating a histogram of the characters 0-9. It subtracts '0' which turns the values in 0-9 for the array reference, then it increments that location in the array. Each position in the array corresponds to a character.

So 0123456789 should create an array of all ones. 0123333 should create an array starting with the values 1114.

It is creating a histogram of the characters 0-9. "c- '0'" turns the value from getchar() into an integer, which acts as the index for the array. This index corresponds to the numbers 0-9. It then increments that array location. Thus, once it has completed running, the array consists of the repetitions for the characters 0-9.

So 0123456789 should result in an array of all ones. 0123333 should result in an array with the values 1114000000.

Source Link
Abtin Forouzandeh
  • 5.9k
  • 4
  • 27
  • 28

It is creating a histogram of the characters 0-9. It subtracts '0' which turns the values in 0-9 for the array reference, then it increments that location in the array. Each position in the array corresponds to a character.

So 0123456789 should create an array of all ones. 0123333 should create an array starting with the values 1114.