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);
}