Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

Java Program to print all the numbers which are less than given key element from a given array.

Get an element and print the elements of array which is less than the element.

Sample Input 1:

5 5 7 9 3 1 4

Sample Output 1:

3 1

Sample Input 2:

5 5 7 9 3 1 8

Sample Output 2:

5 7 3 1

Program or Solution

					    
							
					    
					

Program Explanation

i is initialized to 0 and incremented by 1 at each iteration of both the for loops.

First for loop reads n input numbers from user and stores them in array a[] from location 0 to n-1 using second for loop visit each location serially from 1 to n-1.

if the value located in a postion is lesser than the element given by user, then print the value using system.out.println statement.