What is wrong with my code?

#include
using namespace std;

bool isSorted(int a[],int n)
{
if( n==0 || n==1 )
{return true;}

if(a[0]<a[1])
{
	return true;
}
else
{
	return false;
}	

return(isSorted(a+1,n));

}
int main() {
int n;
int a[1000];

if(isSorted(a,n))
cout<<“true”;
else
cout<<“false”;

return 0;

}

hello @amangupta
image
this is not the sufficient conditon for sorted array.
it should be

if( a[0] <= a[1] && isSorted(a+1,n) ) {
return true;
}
else{
return false;
}

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.