Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ArrayOperation
import java.util.*; class Rextester{ public static void main(String args[]){ int i; int flag=0; int[] a = new int[1000]; System.out.println("How numbers in the array"); Scanner obj =new Scanner(System.in); int n= obj.nextInt(); for(i=0;i<n;i++) { System.out.println("Enter the value for index "+i ); a[i]= obj.nextInt(); } System.out.println("Check for a number in the array Y/N?"); char ch = obj.next().charAt(0); if(ch=='Y'|| ch=='y') { System.out.println("Enter the search element "); int se = obj.nextInt(); for(i=0;i<n;i++) { if(se==a[i]) {flag=1; System.out.println("The element is present at the position number "+i+" in the array set"); } } if(flag ==0) System.out.println("The Element is not present in the array"); } else if(ch=='N'|| ch=='n') System.out.println("Well, Okay. Thanks for testing out this program"); else System.out.println("Wrong Entry,anyways thanks for testing out the code."); } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
cuboid volume
Kochergina_2
exp.1A
Decode byte array
HelloWorld2
evenloop
Application
qwe
Convert string array to lowercase.
bubble sort
Please log in to post a comment.