C Programming
Computer Programming

Program in C to find the smallest number using pointer



Write a Program in c to find the smallest number using pointer

\* C Program to to find the smallest number using pointer *\

# include < stdio.h >
int   main( )
{

int   a[20],n,i,sml  ;
int   *ptr  ;
printf(" How many Numner you want to enter: ") ;
scanf("%d ", & n) ;
printf("\n Enter the number : \n") ;

for (i = 0; i < n ; i++   )
{

scanf("%d ", & a[i]) ;
ptr++  ;

}
ptr = & a[0]  ;
printf(" \n Number you enter :\n ") ;
for (i = 0; i < n ; i++   )
{

printf("\t %d ", ( *ptr )) ;

}
ptr = & a[0]  ;
sml = a[0]  ;
for (i = 0; i < n ; i++   )
{

if ( sml > ( *ptr ))
sml = *ptr  ;
ptr++  ;

}
printf("\n Smallaest element is : %d", sml) ;

return ( 0 );

}

Output of Program :

Output of Program in C to find the smallest number using pointer