Unverified Commit 1087cdbc authored by Lokesh Singh's avatar Lokesh Singh Committed by GitHub

Create Check array is sorted or not

parent 29edbc8e
#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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment