#include
using namespace std;
bool IsSorted(int *a,int n)
{
if(n==0 or n==1)
{
return true;
}
int i = 0 ;
if(a[0]<a[1] and IsSorted(a+1,n))
{
return true;
}
return false;
}
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
if(IsSorted(a,n) == ‘1’);
{
cout<<“true”<<endl;
}
if(IsSorted(a,n) == ‘0’)
{
cout<<“false”<<endl;
}
return 0;
}
What is the error ? Why not ruunning
@dhruvtrehan45
As per your last submitted code just change “True” to “true” and “False” to “false”. your code will work. Here is your updated code: https://ide.codingblocks.com/s/244216
But, It is not working fine when i am submitting code
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.