0

I want to search number in array ,where is fault in the program?

import java.util.*; public class SearchArray { public static void main(String[] args) { int arr[]=new int[3]; int i,n,n1,flag=0; Scanner sc=new Scanner (System .in); System .out .println ("size of array"); n=sc.nextlnt (); System .out .println ("enter the array element"); for(i=0;i<n;i++){ arr[i]=sc.nextlnt (); } System .out .println ("enter search number"); n1=sc.nextlnt (); for(i=0;i<n;i++){ if(arr[i]==n1){ flag=1; System .out .println ("number is present in array"); break; } } if(flag==0){ System .out .println ("number is not present in array"); } } }

9th Apr 2020, 9:29 AM
samrat kundu
samrat kundu - avatar
2 ответов
0
remove the space before evry "." in System.out.println an System.in and it's n=sc.nextInt(); ... arr[i] =sc.nextInt () ; ... n1=sc.nextInt() ; it's an uppercase i (I) not L
9th Apr 2020, 9:39 AM
John Robotane
John Robotane - avatar
0
John Robotane Thank you
9th Apr 2020, 3:01 PM
samrat kundu
samrat kundu - avatar