Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
smallest number and its index(position)
//Aneesh Pradeep 13.01.2020 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a[]=new int[5];//declaration for(int i=0; i<5; i++) { a[i] = sc.nextInt(); } System.out.print("Elements in Array are :\n"); for(int i=0; i<5; i++) { System.out.print(a[i] + " "); } int min=a[0]; int min1=0; for(int i=0; i<5; i++) { if (a[i] < min ){ min=a[i]; min1 = i; } } System.out.println(""); System.out.println("Smallest number = "+min + " and index is " +min1); } }
run
|
edit
|
history
|
help
0
3b
Compiler
A
Menu Combination Sum
Link document
forloop1
karyawan
Counter.java
Problem: on_off
Selection Sort