WAP to search an element in one dimension array
Answers
Answered by
0
Answer:
class abc
{
public static void main (String args [])
{
Scanner sc=new Scanner (System.in);
System.out.println("enter the Length");
int l=sc.nextInt();
int a[]=new int [l];
// input
int i ;
for(i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
// search
System.out.println("enter Number to be searched");
boolean flag = false ;
int pos =0;
for(i=0;i<n;i++)
{
if(a[i]==n)
{
flag =true;
pos=i;
}
}
if(flag== true)
System.out.println("Number found at" + pos+"index");
else
System.out.println("Number Not Found");
}
}
Please Subscribe my Youtube Channel Study To Study ICSE-Swapnil Mehta for more Java Programs
Explanation:
Hope this will help you
Please mark me as brainlist:)
Similar questions
Math,
3 months ago
Computer Science,
3 months ago
English,
7 months ago
Social Sciences,
7 months ago
Math,
11 months ago
Physics,
11 months ago