Maximum Length Bitonic Subarray

Here is my code. I cannot seem to find an error in this. Please rectify and also tell a test case for which it fails. TIA

#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int t,n;
cin >> t;
while(t–){
cin >> n;
int a[n];

	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
	}

	int len = 1, i = 1,maxlen=0;
	while( i < n ){
	    len = 1;
		while(a[i-1] < a[i] && i < n){
			len++;
			i++;
		}
		while(a[i-1] > a[i] && i < n){
			len++;
			i++;
		}
		maxlen = max(len,maxlen);
	}
	cout << maxlen << endl;
}
return 0;

}

check ur first while statement
this is the error in ur code
u have to write while(t–)

2nd check for the test case
15
5 4 3 4 5 4 3 2 1 2 3 4 5 6 2

What are you saying about the while statement. Please clarify.
I have tried the test-case. Answer for the test-case is 7.

but ans is 10
5 4 3 2 1 2 3 4 5 6
first decreasing then in creasing.

oh! i did not realize it could be decreasing first and then increasing. I thought only increasing, only decreasing OR increasing and then decreasing. Thanks. I’ll change accordingly.

if ur doubt got resolved mark it r3solved

but according to question i.e subarray is first increasing and then decreasing or entirely increasing or decreasing. i am getting same answer 7

I used two arrays, inc[n] and dec[n] to solve this problem.
My code gives correct and in all the test cases I applied it to but the CB compiler gives output wrong answer. Can you please tell me the mistake I have made.
My code:-

#include <bits/stdc++.h>
using namespace std;
int main() {
    int testcases;
    cin>>testcases;
    for(int t=0;t<testcases;t++){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int inc[n];
        int dec[n];
        inc[0]=0;
        dec[n-1]=0;
        for(int i=1;i<n;i++){
            if(a[i]>a[i-1]){
                inc[i]=inc[i-1]+1;
            }
            else{
                inc[i]=0;
            }
        }
        for(int k=n-2;k>=0;k--){
            if(a[k]>a[k+1]){
                dec[k]=dec[k+1]+1;
            }
            else{
                dec[k]=0;
            }
        }
        int inc1[n];
        int dec1[n];
        dec1[0]=0;
        inc1[n-1]=0;
        for(int i=1;i<n;i++){
            if(a[i]<a[i-1]){
                dec1[i]=dec1[i-1]+1;
            }
            else{
                dec1[i]=0;
            }
        }
        for(int k=n-2;k>=0;k--){
            if(a[k]<a[k+1]){
                inc1[k]=inc1[k+1]+1;
            }
            else{
                inc1[k]=0;
            }
        }
        // cout<<"inc ";
        // for(int i=0;i<n;i++){
        //     cout<<inc[i]<<" ";
        // }
        // cout<<endl;
        // cout<<"dec ";
        // for(int i=0;i<n;i++){
        //     cout<<dec[i]<<" ";
        // }
        // cout<<endl;
        // cout<<"dec1 ";
        // for(int i=0;i<n;i++){
        //     cout<<dec1[i]<<" ";
        // }
        // cout<<endl;
        // cout<<"inc1 ";
        // for(int i=0;i<n;i++){
        //     cout<<inc1[i]<<" ";
        // }
        // cout<<endl;
        int ans=0;
        for(int i=0;i<n;i++){
            ans=max(ans,max((inc[i]+dec[i]),(inc1[i]+dec1[i])));
        }
        cout<<ans+1<<endl;
    }
}