Sorted Order Check

6.Sorted Order Check

Write a program to find whether the given array is sorted in ascending or descending order.

Input Format:
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the first array. Assume that the maximum value of n is 15.
Output Format:
Print yes if the array is sorted in ascending or descending order. Print no if the array is not sorted in ascending or descending order .
Sample Input 1:
5
2
3
6
8
10
Sample Output 1:
yes
Sample Input 2:
5
20
13
6
4
1
Sample Output 2:
yes
Sample Input 2:
5
20
13
6
4
10
Sample Output 3:
no

code:


No comments:

Post a Comment