Arrays

This is a discussion on Arrays within the C++ Programming forums, part of the General Programming Boards category; First, I just want to state that I am as new to C++ as one can be. I'm an Engineering ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    2

    Arrays

    First, I just want to state that I am as new to C++ as one can be. I'm an Engineering student at PSU, and I am currently enrolled in C++ as the one, and only, computer programming class that I need. So far, I've done well with writing programs, but now I am stumped. We have to write a program that will have 2 functions. 1.) Use an array to let the user enter in 12 numbers. 2.) Have a function to output what the maximum number they entered was. I'm stumped, and our book isn't helping. Any input, advice would be appreciated. Bascially, I just need to know how to let the user enter 12 numbers to be put into an array!! Thanks,
    Joai

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    First, I just want to state that we do not do homework. Second, if the book is not helping at least try to write something and post it here. Then some of us might help you.

    However my policy is that if you are going to school then you have far more resources than I for answering your question. Use them. I do not help with homework.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    94
    Code:
    const int MAX=12;
    int printArray (int [])
    
    
    int main ()
    {
       int numArray[MAX];
    
       cout << "Please enter 12 numbers";
    
       for (int i=0; i<MAX; i++)
         cin >> numArray[i];
    
       printArray(numArray);
       return 0;
    }
    
    //-------------------------------------------
    
    void printArray (int numArray[])
    {
       cout << "The numbers you entered were :   "
    
       for (int i=0; i<MAX; i++)
          cout << numArray[i] << endl;
    
    }
    main contains the for loop to gather the numbers. it then calls the printArray function, which in turn prints the results.


    cheers
    simple is always an understatement.....

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Geez. Just do it for them. Yep they learn good that way.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    94
    sorry

    wasnt thinking when I answered....busy stressing out about my finals
    simple is always an understatement.....

  6. #6
    Registered User
    Join Date
    Nov 2004
    Posts
    2
    Sorry, I wasn't asking for you to actually *do* it for me, but just a general way of doing it. I actually did figure it out .. after lots of reading online. I thought this message board was for help, but I guess it isn't. Sorry.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I thought this message board was for help, but I guess it isn't.
    I'm so tired of people like you saying this. Read the Announcements. We don't do everything for you. The word "help" means "to give assistance". That is to say, we aid you along your path.

    Of course, there are people who do not help but instead do it for you, which is actually what most people really want when they request "help".

    "Help me" is in effect this:
    I'm working on Foo, and I've run into a problem. I have the following code...
    Code:
    int main(  )
    {
        int x;
    
        x = x + 5;
        cout << x;
    
        return 0;
    }
    And it is not giving me the output of 5 like it should. It instead gives me some wierd number. Does anyone know why?
    THAT is a decent request for help. Here, I have shown my attempt at the problem. I have describe the problem. I have described what it should be doing. I have asked for help with discovering why it doesn't do what it should.

    THAT is how you ask for "help".

    But if you'd read the Announcements like you should have, you'd know this.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 03:24 PM
  2. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  3. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 09:47 PM
  4. Building B-Tree from Arrays
    By 0rion in forum C Programming
    Replies: 1
    Last Post: 04-09-2005, 02:34 AM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 08:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21