import java.util.*; import java.lang.*; class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int a[]=new int[100]; int i; System.out.println("enter the numbers"); for(i=0;;i++) { a[i]=sc.nextInt(); if(a[i]==99) break; } for(int p=0;p<=i;p++) if(a[p]==42) break; else System.out.println(a[p]); } }
I would recommend you to see the example. Input and Output Formats are clearly mentioned there. Kindly follow them and don’t put extra statements like :
Also, you need to stop processing input after 42 not 99.
Hope, you got it!