import java.util.Scanner;
class Main{
public static void main(String args[]){
int i,num=8;
int list[]=new int[num];
Scanner input=new Scanner(System.in);
for(i=0;i<list.length;i++){
System.out.println("Enter the array : ");
list[i]=input.nextInt();
}
System.out.println("Enter the location you want to
delete : ");
int pos=input.nextInt();
if(pos>=num+1){
System.out.println("Deletion is not possible ");
}
else
for(i=pos-1;i<num-1;i++){
list[i]=list[i+1];
}
for(i=0;i<num-1;i++){
System.out.println("Array is "+list[i]);
}
}
}
OUTPUT:-
C:\Users\saty\Desktop>javac 1.java
C:\Users\saty\Desktop>java Main
Enter the array :
1
Enter the array :
2
Enter the array :
3
Enter the array :
4
Enter the array :
5
Enter the array :
6
Enter the array :
7
Enter the array :
8
Enter the location you want to delete :
4
Array is 1
Array is 2
Array is 3
Array is 5
Array is 6
Array is 7
Array is 8
No comments:
Post a Comment