Challenge: write a code to find whether the given array of interger elements is sorted or unsorted. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Challenge: write a code to find whether the given array of interger elements is sorted or unsorted.

identify whether the array elements are sorted or unsorted

2nd Mar 2018, 8:40 AM
Amit Gharge
Amit Gharge - avatar
3 Answers
+ 9
use Arrays.sort(array_name); & then by using a loop compare each corresponding element //alternative method also exists without using any loop
2nd Mar 2018, 9:08 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
It is encouraged to make challenges like this into assignments in lesson factory, rather than post them here in the Q/A https://www.sololearn.com/discuss/1082512/?ref=app
2nd Mar 2018, 9:02 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
C++ int arr[50]; for(int& i:arr) cin>>i; cout<<boolalpha<<is_sorted(arr,arr+50);
2nd Mar 2018, 9:59 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar