← Back
Code Challenge 3.5 - Count Occurrences
Objective
Count how many times a specific value occurs in an array.
Skills to Practice
- Array manipulation
- Indexing
Challenge Tasks
- Create a console project named Challenge 3-5.
- Prompt the user to input elements into a collection.
- You may choose whether the elements are integers or floating point numbers.
- Let the user specify the size of the collection.
- Prompt the user to enter a specific value to count within the array.
- Count the occurrences of the specified value within the array without using any built-in count methods.
- Display the count to the user in a clear and formatted manner.
Lists
You may complete this code challenge using a list.
Sample Output
Enter the size of your collection: 6 [Enter]
Enter element 1: 5 [Enter]
Enter element 2: 3 [Enter]
Enter element 3: 5 [Enter]
Enter element 4: 7 [Enter]
Enter element 5: 5 [Enter]
Enter element 6: 8 [Enter]
Enter the value to count: 5 [Enter]
The value 5 appears 3 times in the collection.