Thread: Help with understanding project

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    14

    Help with understanding project

    First off I'm not asking for homework answer, just trying to understand what in the world Im supposted to do. I was given an assignment and didn't understand completey. Asked my professor and she didn't help much (HEAVY accent and Im not to sure she knows what going on anyways).
    So I need to resort to other forms of help. My project is as follows:

    • Write a program to process integer arrays, which will include functions with the following prototypes:

    void array_menu();
    void read_array( int [], int);
    void print_array( int [], int);
    int find_largest( int [], int);
    int find_index_of_largest (int [], int);
    int search_array( int [], int, int);
    float find_average( int [], int);

    In this program, you have to use a define preprocessor directive to define the number of elements in the array as 100. The main function should start with the call to the function read_array, which will initialize array elements to random numbers from 1 to 200 with the help of the functions srand and rand. After that there should be just one do/while loop, which contains a call to the function array_menu, which displays options, and a switch structure that calls one of the functions listed in the menu (depending on the choice). Note that the function print_array should display array elements 10 per line. Follow prototypes exactly!
    Alright, The problem pretty much is, we havent gone over this material. Any examples or explanations will help greatly.

    P.S. There really should be a newb forum for this kinda stuff, and if there is, sorry to bother.

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    What are you having trouble with ? Arrays ? Switch statements ? Functions ? The assignment itself is unclear to you ?

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    i don't really think that you need to have one more int argument in this these two function

    Code:
    void read_array( int [], int);
    void print_array( int [], int);
    Well the size of the array is already accessible through the preprocessor.

    ssharish2005

  4. #4
    Registered User
    Join Date
    Nov 2006
    Posts
    14
    The assignment itself is completely unclear. My professor kinda just said do this. I've never even see half of those prototypes let allow use them.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by ssharish2005
    i don't really think that you need to have one more int argument in this these two function

    Code:
    void read_array( int [], int);
    void print_array( int [], int);
    Sure you do.
    Quote Originally Posted by ssharish2005
    Well the size of the array is already accessible through the preprocessor.

    ssharish2005
    No it isn't.
    Code:
    #include<stdio.h>
    void foo( int bar[] )
    {
        printf("sizeof bar is %d\n", sizeof bar );
    }
    
    int main( void )
    {
        int baz[ 20 ];
        foo( baz );
    
        return 0;
    }
    On that note, now the OP knows pretty much everything they need to to do their homework.

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

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    looks pretty straight forward to me

    make an array of size #define BLAH 100
    call read_array - which will choose random numbers between 1 and 200 and fill the array with them

    have a while loop that calls array_menu

    which itself prints to the screen 5 choices
    ie
    1. print_array
    2. find_largest
    3. find_index_of_largest
    4. search_array
    5. find_average
    6. exit

    based on user input call appropriate function

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. trouble understanding the source file structure
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 05-26-2006, 06:46 PM
  2. Dynamic Binding
    By gpr1me in forum C++ Programming
    Replies: 1
    Last Post: 03-24-2006, 09:01 AM
  3. possible project
    By subdene in forum C++ Programming
    Replies: 6
    Last Post: 09-26-2003, 01:33 PM
  4. DJGPP project problems
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 07:16 PM
  5. c++ OOP project ideas
    By newbie17 in forum C++ Programming
    Replies: 4
    Last Post: 02-25-2002, 12:40 PM