C Programming
Computer Programming

Program in C to find position of smallest element in array



Write a Program in c to find position of smallest element in array

\* C Program to to find position of smallest element in array *\

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

int   a[20], n, sml=0, smlp, i  ;
printf(" Enter the Numbers of terms in Array: ") ;
scanf("%d ", & n) ;
printf("\n Enter the Array of Element : \n") ;
for (  i = 1 ; i < = n ; i++ )
{

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

}
sml = a[1] ;
for (  i = 1 ; i < = n ; i++ )
{

if ( a[i] <= sml )
{

sml = a[i] ;
smlp = i ;

}

}
printf("\n Position of smallest Element is: %d ", smlp) ;
printf("\n Smallest Number is : %d ", sml) ;
return ( 0 ) ;

}

Output of Program :

Output of Program in C to find position of smallest element in array