Thread: Help with counting numbers in arrays

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    Help with counting numbers in arrays

    Can anyone give me any jumping off points on how to make a program where the user inputs N numbers and they get put into an array and then says how many time each number occurs in the array?


    For example, if the user inputs: - 7 3 3 -7 5 5 3 as the elements of your array. Then the program should print:

    5 occurs 2 times
    3 occurs 3 times
    -7 occurs 2 times

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Inputting N numbers into an array N of integers would be a good start.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Counting Numbers in Array, not counting last number!
    By metaljester in forum C++ Programming
    Replies: 11
    Last Post: 10-18-2006, 11:25 AM
  2. Counting occurrence of numbers in C
    By stabule in forum C Programming
    Replies: 1
    Last Post: 11-13-2005, 01:55 AM
  3. about counting prime numbers
    By cengiz in forum C++ Programming
    Replies: 2
    Last Post: 10-28-2003, 06:07 AM
  4. Counting Page Numbers
    By dayknight in forum C++ Programming
    Replies: 2
    Last Post: 11-11-2002, 06:52 AM
  5. counting even numbers
    By slamit93 in forum C++ Programming
    Replies: 5
    Last Post: 04-24-2002, 01:54 PM