answersLogoWhite

0


Best Answer

#include<iostream>

#include<array>

#include<sstream>

std::array<int,10> get_frequency (int range_min, int range_max) {

if (range_max<range_min)

std::swap (range_min, range_max);

std::array<int,10> digit {};

for (int count {range_min}; count<=range_max; ++count) {

std::stringstream ss {};

ss << count;

std::string s {};

ss >> s;

for (auto c : s) {

++digit[c-'0'];

}

}

return digit;

}

int main () {

std::array<int,10> digit {};

digit = get_frequency(1, 89);

std::cout << "In the range 1 to 89...\n";

for (int d {0}; d<10; ++d) {

std::cout << "\tthe digit " << d << " appears " << digit[d] << " times.\n";

}

}

Output:

In the range 1 to 89...

the digit 0 appears 8 times.

the digit 1 appears 19 times.

the digit 2 appears 19 times.

the digit 3 appears 19 times.

the digit 4 appears 19 times.

the digit 5 appears 19 times.

the digit 6 appears 19 times.

the digit 7 appears 19 times.

the digit 8 appears 19 times.

the digit 9 appears 9 times.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the program to figure out how many numbers from 0 to 9 are needed for 1 to 89 for example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you figure out the sum of to nubers that equal 40 and have a difference of 10?

The two numbers needed are 25 and 15


How many significant figures are needed when multiplying two numbers?

It depends on the number of significant figures from two numbers you are multiplying. But when multiplying you use the same number of significant figures from the numbers you are multiplying with the LEAST number of significant figures. Example: 92,873.239 * 2 = 200,000 (because the number 2 has only 1 significant figure even tho 92,873.239 has 8 significant figures your answer still only has 1 significant figure)


What is the advantages of the Roman numbers compared to the Arabic numbers?

Advantages:- Fewer numerals are needed. No nought figure is required for positional place value purposes. Large numbers can be expressed by using the subtractive element of the system.


How do you figure out the square footage needed for drywall in a room?

measure length of the room in feet and then width of the room in feet and multiply the two numbers together


How do you write a program to find out the square and cube of first ten natural numbers in gw basic?

First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.


Why did you do this program?

What program? More information is needed.


What are the differences between your number system and the roman number system?

A nought figure is not needed in the Roman numeral system because the positional place value of these numerals are self evident. A nought figure is needed in the Arabic numeral system (the numbers we use today) to identify the positional place value of these numerals.


What is example of quantitative observation?

Quantitative observations involve numbers. An example would be the volume of 0.1M HCl needed to neutralise 25 ml of sodium hydroxide solution.


Why did Mesopotamia make numbers?

Mesopotamia made numbers because they needed a way to count their goods. They also needed it to sell their goods. They needed to count their money. Mesopotamia made numbers because they needed a way to count their goods. They also needed it to sell their goods. They needed to count their money.


Product disparagement differs from defamation of a nonpublic figure in that?

For a product disparagement case, intent is needed. However, intent is not needed in a defamation case of a nonpublic figure.


How is the zero used?

Zero is needed in numbers for positional place value purposes because it tells us that there is a difference between for example 27 and 207


If needed where can one find directory assistance for phone numbers?

To find directory assistance for phone numbers one would have to call their provider. For example if one belonged to AT&amp;T one could contact their online directory to locate phone numbers.