Increasing decreasing sequence

#include
using namespace std;

int main()
{
int t;
cin>>t;
int prev,curr;
bool isvalid=true;
bool isdecreasing =true;

cin>>prev;
while(t--)
{
    cin>>curr;
    if(curr==prev)
    {
        isvalid=false;
        break;
    }
    
    else if(curr>prev)
    {
        isdecreasing =false;
    }
    
    else if(!isdecreasing && curr<prev)
    {
        isvalid=false;
        break;
    }
    prev=curr;
    
}
cout<<isvalid<<endl;

return 0;

}

PLEASE TELL ME THE PROBLEM IN THIS CODE…AS IT IS NOT SHOWING THE CORRECT OUTPUT.

@dsdishu99
Two changes required :

  1. The output should be boolean instead of 0/1 . Use boolalpha to print bool output .
    cout<< boolalpha << isvalid<<endl;
  2. Your code is working for t inputs. However you have taken one of those inputs before you even began the while loop. Hence you loop should run for t-1 times instead of t times. Change your loop condition to
    while ( --t )

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.

source.cpp: In function ‘int main()’: source.cpp:26:36: error: lvalue required as left operand of assignment 26 | else if(n1>n2 and isdecreasing = false) | ^~~~~

https://ide.codingblocks.com/s/403222 please help with the error