Write a programme to check whether the array is sorted in ascending order or not? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Write a programme to check whether the array is sorted in ascending order or not?

A array is given with some elements in it. You just have to check is it in ascending order or not? if yes then print "true"...

25th Jun 2017, 1:22 PM
Sahil Luthra
Sahil Luthra - avatar
7 Answers
+ 8
// basic algo layout: bool isAscend = true; for (int i = 0; i < array_size - 1; i++) { if (array[i] > array[i + 1]) { isAscend = false; break; } } return isAscend;
25th Jun 2017, 1:28 PM
Hatsy Rei
Hatsy Rei - avatar
+ 8
You may refer to this site for all kinds of algorithms, including array sorting ones. I use bubble-sorting, but it's not the most efficient way. :3 http://bigocheatsheet.com
25th Jun 2017, 1:50 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
nyc logic @Hatsy Rei n one more thing if we need to sort then??
25th Jun 2017, 1:36 PM
Sahil Luthra
Sahil Luthra - avatar
+ 5
coders never ask for which language they just push algorithm​... @Limitless 😂😂😂
25th Jun 2017, 1:41 PM
Sahil Luthra
Sahil Luthra - avatar
+ 4
wow #kamakshi... clapping
10th Aug 2017, 3:02 PM
Sahil Luthra
Sahil Luthra - avatar
+ 2
What programming language?
25th Jun 2017, 1:24 PM
Limitless
Limitless - avatar
10th Aug 2017, 2:47 AM
kamakshi
kamakshi - avatar