OneCompiler

Write a program to accept an array of 20 integer elements and delete an element from the array from the specified position.

236

import java.util.*;
public class array_delete {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
System.out.println("ENTER 20 elements ");
int a[]= new int[20];
for(int i=0;i<20;i++)
{
a[i] = sc.nextInt();
}
System.out.println("ENTER THE POSITION OF THE ELEMENT TO BE DELETED ");
n=sc.nextInt();
System.out.println("DISPLAYING THE ARRAY AFTER DELETING : ");
for(int i=0;i<20;i++)
{
if(i!=(n-1))
System.out.println(a[i]);
}
}
}

FOR CODE : CLICK >> https://onecompiler.com/java/3ynmwqydn TO FIND OUTPUT

SUPPORT US >> https://onethoughttechnology.blogspot.com (OFFICIAL WEBSITE)