title: My function will only return 0.00 when trying to find a percentage
body: <p>I started learning C recently. In this problem when I try to find the percentage of the items under a threshold(both entered by the user) I have to find the percent on items under that threshold as seen in void generateStatistics() at the bottom. When I run this code and enter the required details it only returns 0.00. For example if the user says the threshold is 100 and the amount of items is only 50 it should add one to the i++. Then I can divide and find the percentage. Any help is greatly appreciated thanks.</p>
  
  <pre><code>void generateStatistics(struct node* top)
  {
      struct node* temp = top;
      int departmentChoice;
      int i = 0;
      float percentUnder = 0.00;
  
      /*while (temp != NULL)
      {
          i++;
          temp = temp-&gt;NEXT;
      }*/
  
      printf("Enter 1 for the Office department or 2 for maintainance\n");
      scanf("%d", &amp;departmentChoice);
  
      while (temp != NULL)
      {
          i++;
  
          if (departmentChoice == 1 &amp;&amp; temp-&gt;departmentDelivery == 1)
          {
              if (temp-&gt;numOfUnits &lt; temp-&gt;reorderLimit)
              {
  
                  percentUnder = (percentUnder * 0.100) / i;
                  printf("The percent of items under the reorder threshold is %f\n", percentUnder);
  
              }
              else if ((temp-&gt;reorderLimit * 2) &gt; temp-&gt;numOfUnits  )
              {
  
                  percentUnder = (percentUnder * 0.100) / i;
                  printf("The percent of items under double the reorder threshold is %f\n", percentUnder);
  
              }
              else if ((temp-&gt;reorderLimit * 2) &lt; temp-&gt;numOfUnits)
              {
  
                  percentUnder = (percentUnder * 0.100 ) / i ;
                  printf("The percent of items over double the reorder threshold is %f\n", percentUnder); 
              }
              temp = temp-&gt;NEXT;
          }
  
          if (departmentChoice == 2 &amp;&amp; temp-&gt;departmentDelivery == 2)
          {
              if (temp-&gt;numOfUnits &lt; temp-&gt;reorderLimit)
              {
  
                  percentUnder = (percentUnder * 0.100) / i;
                  printf("The percent of items under the reorder threshold is %f\n", percentUnder);               
              }
              else if (temp-&gt;numOfUnits &lt; (temp-&gt;reorderLimit * 2))
              {
  
                  percentUnder = (percentUnder * 0.100) / i;
                  printf("The percent of items under double the reorder threshold is %f\n", percentUnder);                
              }
              else if (temp-&gt;numOfUnits &gt; (temp-&gt;reorderLimit * 2))
              {
  
                  percentUnder = (percentUnder * 0.100) / i;
                  printf("The percent of items over double the reorder threshold is %f\n", percentUnder);             
              }
              temp = temp-&gt;NEXT;
          }
  
      }
  }
  </code></pre>