title: How to use IF in Switch statement
body: <p>How to apply if condition in Switch statement, I want to calculate Average: however I have tried for best to solve the issue but still getting no output from Switch statement. 
  I am beginner to the C++, </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      //declaration of variables.
      int sub1,sub2,sub3, sub4,sub5,total,avg;
  
      //accepting marks from user in each subject
      cout &lt;&lt; " Enter Programming in C++ Marks: " &lt;&lt; endl;
      cin &gt;&gt; sub1;
      cout &lt;&lt; " Enter Software Engineering Marks : " &lt;&lt; endl;
      cin &gt;&gt; sub2;
      cout &lt;&lt; " Enter Personal Communication Marks : " &lt;&lt; endl;
      cin &gt;&gt; sub3;
      cout &lt;&lt; " Enter Database Application Marks: " &lt;&lt; endl;
      cin &gt;&gt; sub4;
      cout &lt;&lt; " Enter Computer Concept Marks: " &lt;&lt; endl;
      cin &gt;&gt; sub5;
  
      //calculatin sum of marks obtained in each subject
      total = (sub1 + sub2 + sub3 + sub4 + sub5);
  
      //calculating the average marks
      avg = total / 5;
  
      // starting of if condition for finding out grades of total subjects.
  
      switch (avg){
        case 1:{
          if ((avg &gt;= 80) &amp;&amp; (avg &lt;= 100))
          {
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; "You Grade is A+ " &lt;&lt; endl;
          }
          break; 
        }
        case 2:{
          if ((avg &gt;= 70) &amp;&amp; (avg &lt;= 79))
          {
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; " Your grade is A " &lt;&lt; endl;
          }    
          break;
        } 
        case 3:{
          if ((avg &gt;= 60) &amp;&amp; (avg &lt;= 69))
          { 
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; " Your Grade is B+  " &lt;&lt; endl;
          }   
          break;  
        }
        case 4:{
          if ((avg &gt;= 50) &amp;&amp; (avg &lt;= 59))
          {
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; " Your Grade is C+ " &lt;&lt; endl;
          }
          break;
        }
        case 5: {
          if ((avg &gt;= 40) &amp;&amp; (avg &lt;= 49))
          {
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; " Your Grade is  C- ! " &lt;&lt; endl;
          }
          break;    
        }
        case 6: {
          if ((avg &gt;= 30) &amp;&amp; (avg &lt;= 39))
          {
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; " Your Grade is  D ! " &lt;&lt; endl;
          }
          break; 
        }
  
        default:{ 
          if ((avg &gt;= 100) &amp;&amp; (avg &lt;= 29))
          {
              cout &lt;&lt; " Your Average is: " &lt;&lt; avg &lt;&lt; endl;
              cout &lt;&lt; " Your Grade is  F, So you are Fail in the class ! " &lt;&lt; endl;
              break;
          }
        }
      }
  
      system("pause");
  }
  </code></pre>