title: Percent of correct answers program challenge
body: <p>I'm having trouble with the output of my program, the txt files show that the student got 3 answers wrong, but it keeps giving me 0% for percent of correct answers.</p>
  
  <p>The challenge I was given is:</p>
  
  <blockquote>
    <p>"One of your professors has asked you to write a program to grade her ﬁnal exams,
    which consist of only 20 multiple-choice questions. Each question has one of four possible answers: A, B, C, or D. The ﬁle CorrectAnswers.txt contains the correct answers for
    all of the questions, with each answer written on a separate line. The ﬁrst line contains
    the answer to the ﬁrst question, the second line contains the answer to the second question, and so forth. 
    Write a program that reads the contents of the CorrectAnswers.txt ﬁle into a char
    array, and then reads the contents of another ﬁle, containing a student’s answers, into
    a second char array.</p>
    
    <p>The program should determine the number of questions that the student
    missed, and then display the following:</p>
    
    <p>• A list of the questions missed by the student, showing the correct answer and the
    incorrect answer provided by the student for each missed question</p>
    
    <p>• The total number of questions missed</p>
    
    <p>• The percentage of questions answered correctly. This can be calculated as
    Correctly Answered Questions  ÷ Total Number of Questions</p>
    
    <p>• If the percentage of correctly answered questions is 70% or greater, the program
    should indicate that the student passed the exam. Otherwise, it should indicate
    that the student failed the exam.</p>
  </blockquote>
  
  <p>This is the code I have so far, thanks in advance for any suggestions!</p>
  
  <pre><code>#include &lt;iostream&gt; 
  #include &lt;fstream&gt;
  #include &lt;string&gt; 
  using namespace std;
  
  int main()
  {
  const int size=20;
  static int count=0;
  string correctAnswers[size];
  string studentAnswers[size];
  ifstream inFileC;
  
  inFileC.open("c:/Users/levi and kristin/Desktop/CorrectAnswers.txt");
  
  if (inFileC)
  {
  for (int i=0;i&lt;20;i++)
  {
      inFileC&gt;&gt;correctAnswers[i];
  }
  }
  else
  {
      cout&lt;&lt;"Unable to open \"CorrectAnswers.txt\""&lt;&lt;endl;
      cout&lt;&lt;"Please check file location and try again."&lt;&lt;endl&lt;&lt;endl;
  }
  inFileC.close();
  
  ifstream inFileS;
  inFileS.open("c:/Users/levi and kristin/Desktop/StudentAnswers.txt");
  
  if (inFileS)
  {
  for (int t=0;t&lt;20;t++)
  {
      inFileS&gt;&gt;studentAnswers[t];
  }
  }
  else
  {
      cout&lt;&lt;"Unable to open \"StudentAnswers.txt\""&lt;&lt;endl;
      cout&lt;&lt;"Please check file location and try again."&lt;&lt;endl&lt;&lt;endl;
  }
  inFileS.close();
  
  for (int k=0;k&lt;20;k++)
  {
      if (correctAnswers[k]!=studentAnswers[k])
      {
          cout&lt;&lt;endl&lt;&lt;"Correct Answer: "&lt;&lt;correctAnswers[k];
          cout&lt;&lt;endl&lt;&lt;"Student Answer: "&lt;&lt;studentAnswers[k]&lt;&lt;endl;
          count++;
      }
  }
  int percent=((20-count)/20)*100;
  
  cout&lt;&lt;endl&lt;&lt;"Number of missed questions: "&lt;&lt;count;
  cout&lt;&lt;endl&lt;&lt;"Percent of correctly answered questions: "&lt;&lt;percent&lt;&lt;"%";
  
  if (percent&gt;=70)
  {
      cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;"********"&lt;&lt;endl&lt;&lt;"**Pass**"&lt;&lt;endl&lt;&lt;"********"&lt;&lt;endl&lt;&lt;endl;
  }
  else
  {
      cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;"********"&lt;&lt;endl&lt;&lt;"**Fail**"&lt;&lt;endl&lt;&lt;"********"&lt;&lt;endl&lt;&lt;endl;
  }
  return 0;
  }
  </code></pre>