Question

[[c+]] . {{Counting occurrence of numbers}}. Write a program that reads 10 integers between 0 and...

[[c+]] . {{Counting occurrence of numbers}}. Write a program that reads 10 integers between 0 and 99 and counts the occurrences of each.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    int counts[100] = {0};
    int n;
    cout << "Enter ten numbers: ";
    for (int i = 0; i < 10; ++i) {
        cin >> n;
        counts[n]++;
    }
    for (int i = 0; i < 100; ++i) {
        if (counts[i] > 0) {
            cout << "Counts of " << i << " is " << counts[i] << endl;
        }
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
[[c+]] . {{Counting occurrence of numbers}}. Write a program that reads 10 integers between 0 and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (Count occurrence of numbers) Write a program that reads some integers between 1 and 100 and...

    (Count occurrence of numbers) Write a program that reads some integers between 1 and 100 and counts the occurrences of each. Here is a sample run of the program: Enter integers between 1 and 100: 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times 6 occurs 1 time 23 occurs 1 time 43 occurs 1 time 2 5 6 5 4 3 23 43 2 Note that if a number occurs more than...

  • Counting Occurrence of Numbers

    Write a program that reads the integers between 1 and 100 and counts the occurrences of each. Assume the input ends with 0. Here is a sample run of the program:Enter the integers between 1 and 100: 2 5 6 5 4 3 23 43 2 02 occurs 2 times3 occurs 1 time4 occurs 1 time5 occurs 2 times6 occurs 1 time23 occurs 1 time43 occurs 1 timeNote that if a number occurs more than one time, the plural word...

  • C Program Question: Write a program that reads all integers that are in the range of...

    C Program Question: Write a program that reads all integers that are in the range of 0 to 100, inclusive from an input file named: a.txt and counts how many occurrences of each are in the file. After all input has been processed, display all the values with the number of occurrences that were in are in the input file. Note: The program ignores any number less than 0 or greater than 100. Note: Do not display zero if a...

  • Write a program that reads integers, finds the smallest of them, and counts its occurrences. Assume...

    Write a program that reads integers, finds the smallest of them, and counts its occurrences. Assume that the input ends with number -1. Suppose that you entered 4 2 9 2 2 -1; the program finds that the smallest is 2 and the occurrence count for 2 is 3. (Hint: Maintain two variables, min and count. min stores the current min number, and count stores its occurrences. Initially, assign the first number to min and 1 to count. Compare each...

  • *IN PYTHON* (Count single digits) Write a program that generates 1,000 random integers between 0 and...

    *IN PYTHON* (Count single digits) Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list of ten integers, say counts, to store the counts for the number of 0s, 1s, ..., 9s.) Rubric 5 pts: Proper use of list to count occurrences of numbers 5 pts: Proper calculations of counts 5 pts: Proper output Note: No software dev plan or UML required

  • C++counting occurrence of numbers

    write a program that read the integers between 1 and 100 and count the occurrence of each number. Assume the input end with 0. here is samole of the program:Enter the integers between 1 and 100: 2 5 6 5 4 3 23 43 2 0 Enter2 occurs 2 times3 occurs 1 time4 occurs 1 time5 occurs 2 times6 occurs 1 time23 occurs 1 time43 occurs 1 time

  • Write a program that reads a file containing an arbitrary number of text integers that are...

    Write a program that reads a file containing an arbitrary number of text integers that are in the range 0 to 99 and counts how many fall into each of eleven ranges. The ranges are 0-9, 10-19, 20-29,..., 90-99 and an eleventh range for "out of range." Each range will correspond to a cell of an array of ints. Find the correct cell for each input integer using integer division. After reading in the file and counting the integers, write...

  • 1. use c++ write a c++ program that reads 10 integers from a file named input.txt...

    1. use c++ write a c++ program that reads 10 integers from a file named input.txt in this file the 10 integers wil be on a single line with space between the. calculate the average of these numbers and then write his number to a file named output.txt. if the program is unable to successfully complete the file operations then display eero message to the console.

  • (Count the occurrences of each keyword) Write a python program that reads in a Python source...

    (Count the occurrences of each keyword) Write a python program that reads in a Python source code file and counts the occurrence of each keyword in the file. Your program should prompt the user to enter the Python source code filename.

  • Write a C program that generates one hundred random integers between 0 and 9 and displays...

    Write a C program that generates one hundred random integers between 0 and 9 and displays the count for each number. (Hint: Use rand()%10 to generate a random integer between 0 and 9. Use an array of ten integers, say counts, to store the counts for the number of 0’s, 1’s,…..,9’s.)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT