C Programming
Computer Programming

Program in C to insert and display element of array using pointer



Write a Program in c to insert and display element of array using pointer

\* C Program to to insert and display element of array using pointer *\

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

int   a[20], n, i  ;
int   *ptr  ;
printf(" Enter the Number of Element in array: ") ;
scanf("%d ", & n) ;
printf(" \n Enter the element into array: \n ") ;

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

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

}
ptr = & a[0]  ;
printf(" \n Element in array are :\n ") ;
for (i = 0; i < n ; i++   )
{

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

}
return ( 0 );

}

Output of Program :

Output of Program in C to insert and display element of array using pointer