C++ help!!

Hi, I am really struggling with this program i do not even know where to start!

I have to make a program which will initialise an array containing the number of goals scored by a football team in each of their home games so far this season. The program has to display these numbers on the screen, then it also has to add all the goals and output the total number of goals scored.

Er, where did you get this from? Have you some example code from previous lessons that showed how to display stuff?

"Football Team Goals"

Yep, that's what you want to display.

>>

Er, what's this for? Are you thinking this is HTML where you have to match < and >? It isn't, and you don't. Check the hello world program, you should have seen one of these by now:

Code:

cout << "Hello world" << endl;

int goals [10];

Good so far.

int goals [10]

You don't need to do that, you've already defined goals as an int[10].

= { 5, 2, 2, 1, 3,4,2,2,3,5 };

Yep, that's how you initialise an array. Total code for this is

Code:

int goals [10]= { 5, 2, 2, 1, 3,4,2,2,3,5 };

cout:: << "total team goals:">>;

More cout confusion. Have another look at the "hello world" program.

"The program has to display these numbers on the screen"

OK, so you need a for() loop. Have you seen an example of this?

"then it also has to add all the goals and output the total number of goals scored."

OK, so before the for() loop, define a total goals variable and initialise it to zero, and within the loop add the current goal to that variable. After the loop, display the contents of that variable.

Take it a step at a time and don't try to write the program in one go. Get the first bit working, then build and run it to make sure it works. Then add the next bit, and make sure it works, and repeat until the task is complete.