Thread: Arrays

  1. #1
    Registered User
    Join Date
    Nov 2001


    Hi all - im not looking for an entire answer to this question, or anyone to write a program for me (before anyone reminds me of the rules of the board ie. no homework will be done!!). Ive just started a C programming course and have just finished section on arrays and am now starting pointers. Ive been given questions to complete (one of which is below ). My problem is that i dont know where to start with it. I understand the principles and syntax used with arrays etc, but this question is causing me some frustration. Can anyone suggets a way of answering it?


    "Hashing" is a method of storing data in an array so it can be retrieved in an efficient manner. This is done using a hashing algorithm to generate a "hash index" from a given data item (or "key"). The hash index is then used to select the particular array element that will store the data (similar to random files).

    Write a program that uses 2 lists to store data. One list should be student names and the other list the course they are enrolled upon at college. Using students name as "key", the following algorithm will add together the ASCII values of each character in the name and then use the mod operator to convert the total into a range of 0 to MAxNum-1, where MaxNum is the sixe of the array.

    eg using 24 for MaxNum, John Doe = J + O + H + N + D + O + E;
    ie. 74 + 79 + 72 + 78 + 68 + 79 + 69 = 519

    519 % 24 = 15

    Im not sure as how i would go about answering this question. Any ideas at all?

    Thans for your time (and patience!)

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    get your 2 linked lists up and running first.come back with that code and we will try to go from there.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM