Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
4.C
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' // Razak-7051 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int n, x, flag = 0, i = 0; Scanner s = new Scanner(System.in); System.out.print("\nNumber of elements to be entered:"); n = s.nextInt(); int a[] = new int[n]; System.out.println("\nThe list of elements:"); for(i = 0; i < n; i++) { a[i] = s.nextInt(); } System.out.print("\nEnter the element to find:"); x = s.nextInt(); for(i = 0; i < n; i++) { if(a[i] == x) { flag = 1; break; } else { flag = 0; } } if(flag == 1) { System.out.println("\nElement found at position:"+(i + 1)); } else { System.out.println("\nElement not found"); } } }
run
|
edit
|
history
|
help
0
CSV Parser
assignment 3
moneda
2(B)
Coding Numbers - Duplicate - HashSet
Brackets balancing
hello_world_test
Java - SimpleDateFormat(ting) for XML
classwork
Municipiu_Problema_2_Palindrome