Q:

C++ logic issues

It's been a while (Java class last year). Been trying to learn C++ on my own since my school doesn't offer it. I wrote a simple program just to test what I have learned so far - really just the syntax - before I get into intermediate stuff. Anyways I just want to highlight that I am never looking for answers, I rather you question me on my logistics so I can rethink things and possibly finish it on my own. I thought that since I can write this successfully in Java that all would be well in C++ but I am having variable issues. I tried to debug and step through but I still did not understand WHY some of my variables were not getting the values that I assigned them. If you can point me in the right direction, I would really appreciate it.
// This program will create any number of teams the user chooses, 
// give each a score and calculate the average of all the teams.

#include <iostream>
using namespace std;

int main(){

    //number of teams
    int teamCount;
    //array to keep scores
    int team[0];
    //total of scores
    int total=0;
    //average of all scores
    int average=0;

    cout<<"How many teams do you want to keep scores of?"<<endl;

    cin>>teamCount;

    //cout<<teamCount;

    //ask the person for the score as many time
    //as there are teams.
    for(int i=0; i<teamCount; i++){
        cout<< "Give me the score of team "<< i+1<<":"<<endl;
        cin>>team[i];

        total+=team[i];
    }

    average = teamCount/total;

    //output the list of the scores
     for(int i=0; i<teamCount; i++){
         cout<<"Team "<<i+1<<" score is:"<<team[0]<<endl;
     }

    cout<<"and the average of all scores is "<<average<<endl;

    return (0);

} 

A:

Your array
int team[0];

will not work in C++. Btw you can't allocate 0-sized array this way
Try c++ containers instead
std::vector<int> team;

A:

Your team array has no storage associated with it. in C++ arrays are not dynamic, try using a vector instead, and resize it when you read teamCount

A:

In the line
int team[0];

you are creating an array with 0 entries. Arrays in C++ can not increase or shrink. To solve this issue, either allocate the array dynamically after you know how large it needs to be:
int * team = new int[teamCount];

(don't forget to call delete[] team; when you don't need it anymore, or the memory is never reclaimed)
Or better use the object-oriented way and use the class std::vector which is the C++ equivalent for the Java class ArrayList.
Your next mistake is here:
//output the list of the scores
 for(int i=0; i<teamCount; i++){
     cout<<"Team "<<i+1<<" score is:"<<team[0]<<endl;
 }

You are outputting the value of the first team again and again during each loop iteration.
By the way: Both mistakes would be just as wrong in Java :)

