title: Future Value calculator and Exponents
body: <p>Im trying to make a Future value calculator and am not allowed to use the power function. The formula to calculate future value is future value = principal * ( 1 + rate ) ^ (number of periods). Now you cannot use the ^ for exponents in C so i tried using the base and exponent concept which gives me the closest answer to whats expected but still is not right. It gives me a value but its not the correct answer and is too large. If you require more information please ask. </p>
  
  <p>Test run:</p>
  
  <h1>Investment Calculator</h1>
  
  <p>Principal  : 1000
  Annual Rate: 0.06
  No of Years: 5
  The future value is $1338225577600000.000000</p>
  
  <p>the expected result is $1338.23.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  double FutureVal(double prin, double rate,int years);
  
  int main()
  {
  
      double principal;
      double annualRate;
      int  NumYears;
      double result;
  
  
      printf("Investment Calculator\n");
      printf("=====================\n");
  
      printf("Principal  : ");
      scanf("%lf",&amp;principal);
  
      printf("Annual Rate: ");
      scanf("%lf",&amp;annualRate);
  
      printf("No of Years: ");
      scanf("%d",&amp;NumYears);
  
      result = FutureVal(principal,annualRate,NumYears);
  
      printf("The future value is $%lf \n",result);
  
      return 0;
  
  }
  
  double FutureVal(double prin, double rate, int years)
  {
      int i;
      double value = (prin * ( 1 + rate)) ;
      double result = 1;
  
      for (i = 0; i &lt; years; i++)
      {
              result *= value;
      }
      return result;
  
  }
  </code></pre>