#include
using namespace std;
bool isSorted(int *a,int n){
if(n==1)
return true;
else if(a[0]<a[1]&&isSorted(a+1,n-1))
return true;
else
return false;
}
int main() {
int n,i;
cin>>n;
int arr[n];
for(i=0;i<n;i++){
cin>>arr[i];
}
if(isSorted)
cout<<“true”<<endl;
else
cout<<“false”<<endl;
return 0;
}
Why my code is not working
@kundankumarsports2 the condition for checking sorted should be a[0] <= a[1]
Also, you are not sending any arguments in the function call.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.