title: Exam Grading Program in C
body: <p>I'm having a lot of trouble figuring out where and how to start this program. It is an assignment for school, but I <strong>do not</strong> want someone to do it for me. I just want help starting it and getting a foundation built so I can finish it myself. </p>
  
  <p>The assignment is this:</p>
  
  <p>A professor has written a 20 question True/False exam and gave it to all the students of the class. You
  have been asked to write a program that grades this exam. However, to preserve space, the answers to
  each submission are stored in a 20-bit binary number (represented as a decimal). For example, if the
  stored number is 729494, the binary equivalent is 10110010000110010110. This means the answers
  are TFTTFFTFFFFTTFFTFTTF. Each correct answer is worth 1 point, and each incorrect answer is
  worth 0 points. Assume that each student completed the exam (i.e., no omitted answers).</p>
  
  <p>Your program will input a list of student names and answers(for example: "Edwin Larson 568983"), and the program will output the score and
  letter grade for each person(for example: "Edwin Larson 65% D"). Assume that each name (both first and last) cannot exceed 50 characters.
  In order to make this work, your program <strong>must</strong> have the following features.</p>
  
  <p><strong>File Input/Output</strong></p>
  
  <p>Instead of having the user directly enter the input, all input will come from a text file. The first value
  read will be the solution to the exam. All other lines will contain a student’s first name, last name, and
  the number representing his/her answers to the exam. The user should be asked to enter the of the file.
  If the file cannot be found, the user should keep entering the name of the file until a valid input file is
  entered. A sample input file is provided.
  Output should also be done with files. The results of the program should be written to a file. To make
  the project simpler, you may write one score at a time instead of reading the entire input file and then
  writing to the output file. The user should be asked to enter the name of the file. Note that the file does
  not have to exist. If it’s not there, C will create the file automatically. The output should be the student’s
  first and last names, the score (as a percent), and the letter grade.</p>
  
  <p><strong>Structs and Types</strong></p>
  
  <p>Since the exam answers are stored in a 20-bit integer, we need to store the answers in a 20-bit integer.
  To do this, we will use a bit field. To make things simple, we’ll organize this in a struct. At a minimum,
  the struct should contain the student’s first name, last name, and the number storing the answers (with
  20 bits). Define this struct as a new data type called Student.</p>
  
  <p><strong>Macros</strong></p>
  
  <p>Once we compute the score, we need to determine the letter grade. To accomplish this, we will define
  the following macros:
  • IS_A - Check if the score is at least 90.
  • IS_B - Check if the score is between 80 and 89.
  • IS_C - Check if the score is between 70 and 79.
  • IS_D - Check if the score is between 60 and 69.
  If none of these macros return true, then the student gets an F on the exam.</p>
  
  <p><strong>Header File</strong></p>
  
  <p>The struct and the macros should be placed in a separate header file. The main C program will need to
  include this header file.</p>
  
  <pre><code>#ifndef Header_H
  #define Header_H
  
  #define IS_A(x) ((x) &gt;= (90))
  #define IS_B(x) ((x) &gt;= (80) &amp;&amp; (x) &lt;= (89))
  #define IS_C(x) ((x) &gt;= (70) &amp;&amp; (x) &lt;= (79))
  #define IS_D(x) ((x) &gt;= (60) &amp;&amp; (x) &lt;= (69))
  #define IS_F(x) ((x) &lt;= (59))
  
  typedef struct
  {
      char first[25];
      char last[25];
      unsigned int grade;
  
  }Student;
  
  #endif
  </code></pre>
  
  <p>I'm now getting an error stating my header file cannot be included because it cannot be found. I have made sure they're both in the same folder/directory.</p>