Sorted array(recursion)

include
using namespace std;
bool issorted(int a[],int n){
if(n==0){
return true;
}
if(a[0]<<a[1]&&issorted(a+1,n-1)) {
return true;
}
else false;
}
int main(){
int a[1000];
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
if(issorted(a,n))
cout<<“true”;
else
cout<<“false”;}
why it is not working?

Hi @tishya_goyal

You are using a[0]<<a[1] instead of a[0] < a[1]. It gives two correct outputs for test case 2 and 3. But your code is failing on case like : 9 -1 -2. It is returning true instead of false. Try to figure this out.

Hope it Helps.

Corrected Code : https://ide.codingblocks.com/s/193108

@tishya_goyal
Please mark your doubt as solved.

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.