diff --git a/Check array is sorted or not b/Check array is sorted or not new file mode 100644 index 0000000000000000000000000000000000000000..281ac79c3c17dd4b8817bbafb68f4f69b1e6652a --- /dev/null +++ b/Check array is sorted or not @@ -0,0 +1,18 @@ +#include <iostream> +using namespace std; + +bool isSorted(int arr[], int n) +{ + for(int i = 0; i<n;i++) + { + if(arr[i]<arr[i-1]) + return false; + } + return true; +} +int main() { + int arr[] = {5 , 8, 10, 13}; + int n = sizeof(arr) / sizeof(arr[0]);//length of array + cout<<isSorted(arr, n); + return 0; +}