Computer Science, asked by alinapasha19, 3 months ago

Take 10 integer inputs from user and store them in an array. Again ask user to give a number. Now, tell user whether that number is present in array or not.

Answers

Answered by chilapvaishnavi
1

Answer:

I think it will not be present.

I hope it helps u

Answered by vamshik187
0

Answer:

Explanation:

import java.util.*;

public class Main

{

 public static void main (String[]args)

 {

   Scanner in = new Scanner (System.in);

   int number;

     System.out.print ("Enter the lenth of array:-");

     number = in.nextInt ();

   int[] array = new int[number];

   for (int i = 0; i < array.length; i++)

     {

System.out.print ("Enter [" + i + "] number  of array:-");

array[i] = in.nextInt ();

     }

   //System.out.print(Arrays.toString(arr));

   System.out.print ("Enter number to find:-");

   int n = in.nextInt ();

   boolean numberfound = isNumberpresent (array, n);

   if (numberfound == true)

     {

System.out.print (n + " found in Array");

     }

   else

     {

System.out.print (n + "  not  found in Array");

     }

 }

 public static boolean isNumberpresent (int[]num, int z)

 {

   for (int i = 0; i < num.length; i++)

     {

if (num[i] == z)

  {

    return true;

  }

     }

   return false;

 }

}

Similar questions