Write a program that reads in a set of positive integers and outputs how many times a particular number appears in the list. You may assume that the data set has at most 100 numbers and -999 marks the end of the input data. The numbers must be output in increasing order. For example, for the data 15 40 28 62 95 15 28 13 62 65 48 95 65 62 65 95 95 -999
Write a program that reads in a set of positive integers and outputs how many times a particular number appears in the list. You may assume that the data set has at most 100 numbers and -999 marks the end of the input data. The numbers must be output in increasing order. For example, for the data
15 40 28 62 95 15 28 13 62 65 48 95 65 62 65 95 95 -999
The output is
Number Count
13 1
15 2
28 2
40 1
48 1
62 3
65 3
95 4
Given that,
A program that reads in a set of positive integers and outputs how many times a particular number appears in the list.
Algorithm:
- Start
- Input the array elements
- Check index less than 100 and element is -999
- Loop to arrange elements ascending order
- Loop to sort array elements
- Loop to print frequencies
- Check if same number repeated
- else the number is different
- Print the output numbers in increasing order
- End
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images