C Programming
Computer Programming

Program in C to delete a number from given position in an array



Write a Program in c to delete a number from given position in an array

\* C Program to to delete a number from given position in an array *\

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

int   a[20], i, n, pos  ;
printf(" Enter the Numbers of elements: ") ;
scanf("%d ", & n) ;
printf("\n Enter the element of araay : \n") ;
for (  i = 1 ; i < = n ; i++ )
scanf("%d ", & a[i]) ;
printf("\n Array elements enter by use are :\n") ;
for (  i = 1 ; i < = n ; i++ )
printf("%d \t", a[i]) ;

printf("\n Enter a position at you want to delete the element :") ;
scanf("%d ", & pos) ;

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

if (  i < pos  )
a[i] = a[i] ;
else
a[i] = a[i+1] ;

}
printf("\n Array after deleting the particular element :\n") ;
for (  i = 1 ; i < n ; i++ )
pcanf("%d \t", a[i]) ;
return ( 0 ) ;

}

Output of Program :

Output of Program in C to delete a number from given position in an array