We are required in our assignment to find the second smallest integer in one array recursively. However, for the sake of understanding the subject more, I want to do it iter
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter array size = ");
int size=in.nextInt();
int[] n = new int[size];
System.out.println("Enter "+ size +" values ");
for(int i=0;in[i]){
ssmall=small;
small=n[i];
}else if(ssmall>n[i])
ssmall=n[i];
}
// finding second small if first element itself small
if(small==n[0]){
ssmall=n[1];
for(int i=1;in[i]){
ssmall=n[i];
}
}
}
System.out.println("Small "+ small+" sSmall "+ ssmall);
in.close();
}