WAP to search a numbers from given list in Java

Free Java Programs

Write a program to search a numbers from given list

import java.io.*;
class search
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int arr[]=new int[10],i,temp,j,num;
System.out.println("Enter an array of 10 numbers");
for(i=0;i<10;i++)
{
arr[i]=Integer.parseInt(br.readLine());
}
System.out.println("Enter number to be searched");
num=Integer.parseInt(br.readLine());

for(i=0;i<10;i++)
{
if(num==arr[i])
{
System.out.println("Number found on position ="+(i+1));
break;
}

}
if(i==10)
System.out.println("Number not found");
}
}

1 Comments

  1. sir in ths programming there is no any use of verible"temp" then why it is taken??????

    ReplyDelete
Previous Post Next Post