1. ## Array assignment

I have a project that requires I take user input from menu options and put it into an array which I will average out. I can set the menu up I think, but I cannot understand how to put what the user inputs into an array. Granted I just took the lecture on arrays today. Also we can only use functions to do the work. A little direction is all I need.

2. Code:
```int user_input;

/* read user input here */

array[i] = user_input;```
what's the problem?

3. I have to setup a menu that allows the user to input an integer between 1-5 for seven days:

Please enter level for day 1:
Please enter level for day 2:
etc...

the program will enter each entry into an array. Then take the array and average the elements and then the average has to be output to a corresponding color.

4. Did you have a specific question? vart already illustrated how to read input into an array (although you don't necessarily need an additional variable - you can read right into the array). Requesting the same input a few times in a row implies a loop of some kind.

Rather than look at your entire assignment as one big task, break it down into smaller tasks and just focus on one at a time. First, write code to prompt for input, read that input, and print it out (I'm assuming you've already done some of these things). When that works, figure out how to repeat the prompt, and store the results in an array (each element of the array is its own variable), then print out the array. When that works, start the next part (averaging or whatever). Break the problem down into smaller problems and solve them (i.e. code, compile, and test) each one at a time.

5. Code:
```double average(const int* arr, unsigned int siz)
{
assert(arr && siz);
const double n = (double)siz;
int sum = 0;
do {
sum += *arr++;
} while( --siz );
return (double)sum / n;
}```

6. @zub - While your desire to help is commendable, you should avoid providing complete solutions to new programmers - especially without any explanation of what the code does. We want to help people learn how to program, and that means giving them clues or advice so they can get to the final result on their own. Just giving out answers does not help the learning process.

7. He expressed his ideas so vague that I'm not sure my solution suitable for him. Most likely, he will have to understand the code and change it. Thus, it can be considered only a hint. Also, my style badly perceived by beginners. I am convinced that many times. Thus, he will have to study my code very carefully, checking every second with books. I'm sure it will bring more benefit to him than a hundred correct but vague advices.

8. I hear ya Matticus. Thanks for the code Zub, but there is no way I can get away with that. I am working on it piece by piece but I am way overwhelmed by the individual pieces. I will work on one module at a time. I have the first function pretty much worked out. Functions and arrays are totally new to me so they are a little hard to wrap my head around conceptually. I will post as I go along. Thank you for your responses thus far and I look forward to your further input.

9. Originally Posted by zub
He expressed his ideas so vague that I'm not sure my solution suitable for him. Most likely, he will have to understand the code and change it. Thus, it can be considered only a hint. Also, my style badly perceived by beginners. I am convinced that many times. Thus, he will have to study my code very carefully, checking every second with books. I'm sure it will bring more benefit to him than a hundred correct but vague advices.
You make some good points, but your approach can go either way. Either the code can be studied and learned from, or blindly copied and used (I'm not suggesting the OP would do this - I'm making a generalized statement).

In addition, if the latter occurs, there are several potential negative consequences.

- Lack of a "figuring it out yourself" learning experience (the most valuable kind);
- Bad grade if whoever is grading the program sees code that is beyond the abilities of the student.

The first point is probably the most important. One can read from a source and think they have understanding, only to realize they don't when they no longer have something to reference. Struggling to develop these skills is the best way to master this knowledge.

The second point can be bad either way - if they do get a good grade for something they didn't do themselves, they will advance to more difficult level and not be prepared since they didn't learn basics as well as they could have. Worst case scenario - they get through their education without proper knowledge and end up working in the field where they inhibit the work of others who know their stuff.

On the other hand, the "guide them to the right answer" approach has none of these problems.

10. Originally Posted by Cody Staus
I hear ya Matticus. Thanks for the code Zub, but there is no way I can get away with that. I am working on it piece by piece but I am way overwhelmed by the individual pieces. I will work on one module at a time. I have the first function pretty much worked out. Functions and arrays are totally new to me so they are a little hard to wrap my head around conceptually. I will post as I go along. Thank you for your responses thus far and I look forward to your further input.
The best part about programming is how easy it is to create little "test programs" to play with concepts and get an understanding of them.

Also, there's an example of building up a small program piece by piece here, if it helps to see an example -> A development process