title: How can you initialize a range of values into a variable. e.g. 80 to 100=A and 75 to 79=B etc
body: <p>** The problem is it doesn't work since it keeps printing an A for all averages. Even though one gets an average of 30 it still says that your average is 30 and your grade is A.**</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  #define newline '\n';
  int main()
  {
      int studentno;
      string name;
      float marks[8];
      float sum=0;
      double average;
  
  
      cout&lt;&lt;&quot;Please enter your full names&quot;&lt;&lt;newline;
      getline(cin,name);
      cout&lt;&lt;endl;
  
      cout&lt;&lt;&quot;Please enter your student number :&quot;&lt;&lt;newline;
      cin&gt;&gt;studentno;
      cout&lt;&lt;endl;
  
      for(int i = 0; i&lt;8; i++)
      {
          cout&lt;&lt;&quot;Please enter the marks of the student :&quot;;
          cin&gt;&gt;marks[i];
          cout&lt;&lt;endl;
          sum += marks[i];
      }
  
      average = sum/8;
  
      #So from this point, I have subdivided the sections into different ranges whereby if a person has an average of 85 then its an A, and if an average of 76 then its an A-. The problem is it doesn't work since it keeps printing an A for all averages.  
  
      if(80.0&lt;= average &lt;=100)
      {
        cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is A &quot;&lt;&lt;endl;
      }
  
      else if(75.0&lt;= average &lt;=79.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is A- &quot;&lt;&lt;endl;
      }
  
      else if(70.0&lt;= average &lt;=74.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is B+ &quot;&lt;&lt;endl;
      }
  
      else if(65.0&lt;= average &lt;=69.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is B &quot;&lt;&lt;endl;
      }
  
      else if(60.0&lt;= average &lt;=64.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is B- &quot;&lt;&lt;endl;
      }
  
      else if(55.0&lt;= average &lt;=59.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is C+ &quot;&lt;&lt;endl;
      }
  
      else if(50.0&lt;= average &lt;=54.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is C &quot;&lt;&lt;endl;
      }
  
      else if(45.0&lt;= average &lt;=49.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is C- &quot;&lt;&lt;endl;
      }
  
      else if(40.0&lt;= average &lt;=44.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is D+ &quot;&lt;&lt;endl;
      }
  
      else if(35.0&lt;= average &lt;=39.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is D &quot;&lt;&lt;endl;
      }
  
      else if(31.0&lt;= average &lt;=34.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is D- &quot;&lt;&lt;endl;
      }
  
      else if(0.0&lt;= average &lt;=30.9)
      {
          cout&lt;&lt;&quot;Your average is :&quot;&lt;&lt;average&lt;&lt;&quot; and your grade is E &quot;&lt;&lt;endl;
      }
  
      else
      {
          cout&lt;&lt;&quot;Invalid marks input please check again and correct where you went wrong&quot;&lt;&lt;endl;
      }
  
      return 0;
  }
  </code></pre>
  <p><strong>This is the output</strong></p>
  <pre><code>Please enter your full names
  James Bond
  Please enter your student number :
  007
  Please enter the marks of the student :12
  Please enter the marks of the student :20
  Please enter the marks of the student :30
  Please enter the marks of the student :23
  Please enter the marks of the student :24
  Please enter the marks of the student :21
  Please enter the marks of the student :7
  Please enter the marks of the student :13
  Your average is :18.75 and your grade is A
  </code></pre>
  <p><em>As you can see, it says an average mark of 18.75 is equivalent to an A which isn't what i wrote on the code.</em></p>