Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ logic issues
    primarykey
    data
    text
    <p>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.</p> <pre><code>// This program will create any number of teams the user chooses, // give each a score and calculate the average of all the teams. #include &lt;iostream&gt; 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&lt;&lt;"How many teams do you want to keep scores of?"&lt;&lt;endl; cin&gt;&gt;teamCount; //cout&lt;&lt;teamCount; //ask the person for the score as many time //as there are teams. for(int i=0; i&lt;teamCount; i++){ cout&lt;&lt; "Give me the score of team "&lt;&lt; i+1&lt;&lt;":"&lt;&lt;endl; cin&gt;&gt;team[i]; total+=team[i]; } average = teamCount/total; //output the list of the scores for(int i=0; i&lt;teamCount; i++){ cout&lt;&lt;"Team "&lt;&lt;i+1&lt;&lt;" score is:"&lt;&lt;team[0]&lt;&lt;endl; } cout&lt;&lt;"and the average of all scores is "&lt;&lt;average&lt;&lt;endl; return (0); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload