Computer Science, asked by hemabindu, 11 months ago

write a java program to accept and store 10 elements in a single dimensional array and enter the new element and check whether the element is present or not by using selection Sort algorithm​

Answers

Answered by rakeshchennupati143
1

Program

import java.io.*;

import java.util.*;

public class Main{

   public static void main(String args[]){

       int arr[] = new int[10];

       Scanner sc = new Scanner(System.in);

       System.out.println("Enter 10 elements into the array");

       for(int i = 0; i < 10; i++){

           arr[i] = sc.nextInt();

       }

       System.out.println("Enter number to check : ");

       int temp = sc.nextInt();

       for( int i = 0 ; i < 10 ; i++ ){

           if( arr[i] == temp ){

               System.out.println("given number found at "+(i+1)+" position");

               break;

           }

       }

   }

}

Output

Enter 10 elements into the array

12

14

56

34

786

345

23

987

5467

3

Enter number to check : 5467

given number found at 9 position


hemabindu: tq tq soo much
rakeshchennupati143: my pleasure!
hemabindu: i have one more question shall i ask
rakeshchennupati143: yea for sure anything
Similar questions