7. Write a program to delete an element at desired position from an array.
PROGRAM:
import [Link];
class lab6ha
{
public static void main(String args[]){
Scanner sc=new Scanner([Link]);
int array[]=new int[100];
int pos,c,n;
[Link]("Enter number of elements in array");
n=[Link]();
[Link]("Enter "+n+" Element:");
for(c=0;c<n;c++)
array[c]=[Link]();
[Link]("Enter the desired position to delete the element in an array");
pos=[Link]();
if(pos>=n+1)
[Link]("Deletion not possible.");
else
{
for(c=pos-1;c<n-1;c++)
array[c]=array[c+1];
[Link]("Resultant array is");
for(c=0;c<n-1;c++)
[Link](array[c]);
}
}}
OUTPUT: