Write a C program to find the smallest element in an array of 10 elements using pointers.

Program:
include<stdio.h>
main()
{
int i,A[10],small,index=1;
int *p;
p=A;
clrscr();
printf("Enter the array elements\n");
for(i=0;i<10;i++)
scanf("%d",&A[i]);
small=*p;
for(i=1;i<10;i++)
{
p++;
if(small>*p)
{
index=i+1;
small=*p;
}
}
printf("Smallest element in an array %d is found at %d position\n",small,index);
getch();
}

 

Output:
Enter the array elements
66
99
-9
-8
-6
-3
55
66
-99
89
Smallest element in an array -99 is found at 9 position

Enter the array elements
88
99
-8
-6
0
23
12
45
69
88
Smallest element in an array -8 is found at 3 position