title: C++ Exam Grader
body: <p>Alright, I've been able to simply the code. My current issue is dealing with the output. Looping structures to include 5 students but have the number elements reset like the percentages and answeredCorrectly. Also at the end of questions missed portion, I have to add in what the correct answer is. Our professor gave us 2 functions in order to accomplish this, I just do not understand how to implement them correctly. That code is not posted, but if anyone is interested in helping solve that problem, Ill be happy to post it.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;cstdio&gt;
  using namespace std;
  
  int main()
  {
      int z = 0;
      const int WRONGQUESTIONS = 20;
      int wrongCounter[WRONGQUESTIONS];
      const int QUESTIONS = 20; 
      const int STUDENT_QUESTIONS = 100;
      ifstream inputFile;
      inputFile.open("CorrectAnswers.txt");
      char correctAnswers[QUESTIONS];
      for (int i=0; i&lt;20; i++)
      {
          inputFile &gt;&gt; correctAnswers[i]; 
      }
  
      ifstream inputFile2;
      inputFile2.open("StudentAnswers.txt");
      char studentAnswers[STUDENT_QUESTIONS];
      for (int t=0; t&lt;STUDENT_QUESTIONS; t++)
      {
          inputFile2 &gt;&gt; studentAnswers[t];
      }
  
  int answeredCorrectly = 0;
  for(int c = 0; c &lt; 5; c++)
      {
          int z = 0;
      //now we use a for loop to go through the questions and store whether the answer was right or wrong
      for (int x = 0; x &lt; QUESTIONS; x++)
          {      
  
              if (studentAnswers[x] == correctAnswers[x])
                  answeredCorrectly++;
              else
                  wrongCounter[z]++;
              z++;
          }
                  cout &lt;&lt; "Report for Student " &lt;&lt; c+1 &lt;&lt; ":" &lt;&lt; endl;
                  cout &lt;&lt; "---------------------" &lt;&lt; endl;
                  cout &lt;&lt; "Missed " &lt;&lt; 20 - answeredCorrectly &lt;&lt; " out of 20 questions for " &lt;&lt; (answeredCorrectly / 20) * 100 &lt;&lt; "% correct." &lt;&lt; endl;
                  cout &lt;&lt; "Answered Correctly:  " &lt;&lt; answeredCorrectly &lt;&lt; endl;
                  cout &lt;&lt; "Questions missed:" &lt;&lt; endl &lt;&lt; endl;
  
      }
  }
  </code></pre>