Thread: Need Help generating an array

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    5

    Need Help generating an array

    I have this sample code that my instructor gave so I can be able to create a program similar for extra points

    Code:
    #include<stdio.h>
    /*Put the Prototype here */
    #define NUMINTS 10
    int main(void)
    { int values[NUMINTS]={5,10,30,42,18,24,50,88,62,99};
    int skey=0,n,index;
    printf("\nEnter Search Key ID or -1 to terminate: ");
    scanf("%i",&skey);
    while(skey!=-1)
    { if ((index=seqsearch(values,NUMINTS,skey))==-1) 
    printf("\nNo match found for: %i \n",skey);
    else
    printf("\nValue: %i found at index %i\n", skey,index);
    printf("\nEnter Search Key ID or -1 to terminate: ");
    scanf("%i",&skey);
    }
    puts("\nGOODBYE\n");
    return 0;
    } //END MAIN Function definitions come next
    Now I am not sure what is wrong with it but i get 2 errors and I been trying to fix it.
    Error 1 error LNK2019: unresolved external symbol _seqsearch referenced in function _main Array.obj

    Error 2 fatal error LNK1120: 1 unresolved externals F:\Csci 180\Assignment5\Debug\Assignment5.exe


    This program will help with my extra pt assignment:
    Write a program which performs the following actions:
    1) Generates an array with 100 integers with random values between 1 and 1000.
    2) Sort the array (using either selection sort or bubble sort)
    3) print the sorted array
    4) Ask the user for a number to search for
    5) Search the array with binary search.
    6) Indicate whether or not the value was found.
    7) repeat steps 4-6 until the user enters -1 for the search value

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    this sample code has a horrible indentation. It is unreadable.

    The linker just told you that you have forgotten to write a function that will do all the work for you
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Fix your indentation, and do what your homework asks. It's incomplete code, it's not meant to compile right now. You have to start filling in the blanks. Your error messages should help tell you what you need to do.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    5
    well for one it is NOT homework the semester is over..its extra credit and this code came from the instructor's notes which was suppose to be done and there to help with the extra credit. there is no fill in the blank from what i understood..and it was okay to use any if not all of the code to help with prog.
    Thank u all anyways.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by msbrownsugah View Post
    well for one it is NOT homework the semester is over
    That's funny...
    Quote Originally Posted by msbrownsugah View Post
    ..its extra credit and this code came from the instructor's notes which was suppose to be done
    Sure sounds like homework to me.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Where it says "Put a prototype here", you will be expected to put a prototype, I'm sure.

    And if you have to put a prototype there, and call a function, then you'll need to write that function, of course.

    We don't do a lot of that type of help here, because we'd be completely buried in it by students, please understand.

    Post back when you have a more specific question about this.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    5
    yes I completely understand ..I went to the "source" ...my instructor ..and I was able to get it corrected so thanks for responses..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  2. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. Array Program
    By emmx in forum C Programming
    Replies: 3
    Last Post: 08-31-2003, 12:44 AM