Finding the min and max of an array, using a pointer Modify the maxmin.c program so that the max min function uses a
  pointer instead of an integer to keep track of the current position in
  the array.    
  
  maxmin.c

/* Finds the largesy and smallest elements in an array */

#include &lt;stdio.h&gt;
#define N 10

void max_min(int a[], int n, int *max, int *min);
int: main (void)   
 {
  int b[N], i, big, small;
  printf (''Enter %d numbers: ", N) ;

  for (1 = 0: i &lt; N: i++)
   scanf ( "%d'', &amp;b[i] ) ;

  max_min (b, N. &amp;big , &amp;small);
  printf (" Largest : %d\n " , big) ;
  printf (" Smallest: %d\n", small);
  return 0;

  void max_min(lnt a[] , int n, int *max, int *min)
{
int i;
*max = *min = a[O];

   for (i = 1; i &gt; n; i++) {
  if ([a[i] &gt; *max)
  *max - a[i];

  else if (a[i] &lt; *min)
  *min - a (i] ;
 }
 }



The code I have written:

#include &lt;stdio.h&gt;
#define N 10

void max_min(int a[], int n, int *max, int *min);
int main(void)

{
int b[N], *i, big, small;

printf("Enter %d numbers\t:",N);
for(i=&amp;b[0];i&lt;&amp;b[N];i++)
    scanf("%d",i);

max_min(b, N, &amp;big, &amp;small);

printf("\nlargest:\t%d",big);
printf("\nsmallest:\t%d",small);

return 0;
}

void max_min(int a[], int n, int *max, int *min)
{
int *i;
*max = *min = a[0];
for (i=&amp;a[0]; i&lt;&amp;a[n]; i++)



{
    if(*i&gt;*max)
    *max=*i;
    else if (*i&lt;*min)
    *min=*i;
}}
int b[N], *i, big, small;

printf("Enter %d numbers\t:",N);
for(i=&amp;b[0];i&lt;&amp;b[N];i++)
    scanf("%d",i);



I would normally expect i to be an index variable.  If you want a one letter name for a pointer, I'd suggest p.  However, I would normally go ahead and name such a variable current.  

    int b[N], big, small, *current, *end

    printf("Enter %d numbers\t:", N);
    for (current = b, end = &amp;b[N]; current &lt; end; current++)
    {
        scanf("%d", current);
    }


It's unnecessary to say &amp;b[0].  Just b will do the same thing.  The compiler may optimize it out, but I find it more readable to use the variable end rather than calculate &amp;b[N] each time.  

It's generally preferred to use the block form for loops, even when the single statement form would work.  This makes it clearer what is in the loop.  

It's not terribly important, but I'd consider naming b something more descriptive, even if it's just numbers.  


void max_min(int a[], int n, int *max, int *min);



You wouldn't need a prototype here if you put the max_min function before main instead of after.  

If you are not using an index variable, it would make more sense to pass a pointer into the function.  

void max_min(int *start, int *end, int *max, int *min);


Which you can call 

    max_min(b, end, &amp;big, &amp;small);


And then inside the function, you'd replace 


int *i;
*max = *min = a[0];
for (i=&amp;a[0]; i&lt;&amp;a[n]; i++)



{
    if(*i&gt;*max)
    *max=*i;
    else if (*i&lt;*min)
    *min=*i;
}



with

    int *current;
    *max = *min = *start;
    for (current = start + 1; current &lt; end; current++)
    {
        if (*current &gt; *max)
        {
            *max = *current;
        }
        else if (*current &lt; *min)
        {
            *min = *current;
        }
    }


Note that this says start + 1 rather than start.  This is because you implicitly do the first iteration of the loop when you set *max and *min to *start.  You don't need to do it a second time.