text: /* Code for demonstrating Fixed point Method */
  
  #include <stdio.h>
  #include <time.h>
  #include <math.h>
  
  int main()
  {
      float x=0.5, Es = 0.0005, Ea = 10000, e[100]; /* Defining x and errors */
      int counter = 0, i; /* Defining Counter for iteration count */
  
      clock_t begin = clock(); /*Clock staring from this line*/
  
      printf("Program to solve Non-linear Equation using Fixed Point Method :\n");
      printf("---------------------------------------------------------------\n");
      printf("Initial Estimate : %f\n",x);
  
      FILE *fptr = fopen("FixedPoint_Error.csv", "w"); /* Opening file for storing errors of Fixed Point Method */    
      
      while (fabs(Ea) > Es)
      {
          Ea = x;
          x = pow( 20 + 2*x, 0.4 ) / 4.84936;
          Ea = x - Ea;
          e[counter] = fabs(Ea);
          counter += 1;
      }
  
      fprintf(fptr, "Ea\n"); /* Loop for storing values in file for further plotting */
      for (i = 0; i < counter; i++)
      {
          fprintf(fptr, "%f\n", e[i]);
      }
  
      fclose(fptr);/* Closing file after storing values */
  
      printf("Solution : %0.5f\n",x);
      printf("No. of Iteration : %d\n", counter);
  
      clock_t end = clock();                                                               /* Clock Ends here */
      double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;                          /* Calculating time taken for code to execute */
      printf("Time taken for code execution : %0.6f milli seconds.\n", 1000 * time_spent); /* Printing the time taken */
  
      return 0;
  }