In this program, you will find the largest and smallest number in the c program using a pointer.
#include<stdio.h>
int main()
{
int a[5],max,min,*p,i,n;
p=a;
printf("enter the size of array:");
scanf("%d",&n);
printf("enter the number:");
for(i=0;i<n;i++)
{ scanf("%d",(p+i)); }
max=*p;
min=*p;
for(i=0;i<n;i++)
{
if(*(p+i)>max)
{ max=*(p+i); }
if(*(p+i)<min)
{ min=*(p+i);}
}
printf(" maximum is %d and minimum is %d",max,min);
return 0;
}
enter the size of array:5 enter the number:2 1 3 5 4 maximum is 5 and minimum is 1