Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
smallest number and its index(position)
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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); } }
2 3 1 4 2
[
-
]
Show input
Compilation time: 0.63 sec, absolute running time: 0.2 sec, cpu time: 0.22 sec, memory peak: 20 Mb, absolute service time: 0,84 sec
edit mode
|
history
|
discussion
Elements in Array are : 2 3 1 4 2 Smallest number = 1 and index is 2