/******************************* PLOOP.CPP ************************************
* Example showing the use of pointers and arrays in a loop         1998-09-02 *
*                                                                   Agner Fog *
*                                                                             *
* The same loop is made in three different ways.                              *
******************************************************************************/
#include <iostream.h>
#include <conio.h>

const int ARRAYSIZE = 10;

void main ()
{
   int i;  float f[ARRAYSIZE];  float * p;

   // method 1: index through array
   for (i=0; i<ARRAYSIZE; i++)  cout << f[i] << "\n";


   // method 2: use pointer to go through array
   p = f;
   for (i=0; i<ARRAYSIZE; i++)
   {
      cout << *p << "\n";
      p++;
   }


   // method 3: use pointer also as loop counter
   for (p=f; p<f+ARRAYSIZE; p++)  cout << *p << "\n";

   getch();
}



