Check if an array is sorted ascending

Report a typo

Write a program that reads an array of int's and checks if the array is sorted ascending (from smallest to largest number).

Input data format

The first line contains the size of an array.
The second line contains elements of the array separated by spaces.

Output data format

Only a single value: true or false.

Sample Input 1:

4
1 2 3 4

Sample Output 1:

true

Sample Input 2:

4
1 2 3 0

Sample Output 2:

false
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic