Created
September 11, 2016 18:16
-
-
Save manish84ya/d3c7f1da8c1a996f5acc1a0d68cc1fd6 to your computer and use it in GitHub Desktop.
Write a program to read an integer array and remove all 10s from the array, shift the other elements towards left and fill the trailing empty positions by 0 so that the modified array is of the same length of the given array. Include a class UserMainCode with a static method removeTens which accepts the number of elements and an integer array. T…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Question1 { | |
public static void main(String[] args){ | |
Scanner sc=new Scanner(System.in); | |
System.out.println("Enter The Number"); | |
int i; | |
int temp=0; | |
//int b[]=null; | |
int j; | |
int n=sc.nextInt(); | |
int a[] = new int[n]; | |
for( i=0;i<n;i++){ | |
a[i]=sc.nextInt(); | |
} | |
for( i=0;i<n;i++){ | |
if(a[i]!=10) | |
{ | |
System.out.println(a[i]); | |
} | |
} | |
for(i=0;i<n;i++){ | |
if(a[i]==10){ | |
temp=a[i]%10; | |
System.out.println(temp); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment