# Help me in solving RATINGINPRAC problem

### My issue

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

``````  for(int i=1;i<n;i++){

if(a[i-1]>a[i]){
cout<<"No"<<endl;

}
cout<<"YES"<<endl;
``````

}
}

``````return 0;
``````

}
getting this output
YES
YES
YES
YES
YES
YES
YES
No
YES
YES
YES
No
YES
No
YES
how to get output correct output this is showing comparison of every element present in an array.

### My code

``````#include <iostream>
using namespace std;

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

if(a[n-1]>a[n]){
cout<<"No"<<endl;

}
cout<<"YES"<<endl;

}

return 0;
}

``````

Learning course: Arrays using C++
Problem Link: CodeChef: Practical coding for everyone

@palakkatare_01
Your logic is not right .
U have to check whether the array is in increasing order or not.
like this

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int ch=0;
for(int i=1;i<n;i++)
{
if(a[i]<a[i-1])
{
ch=1;
}
}
if(ch)
cout<<"NO";
else
cout<<"YES";
cout<<endl;
}
return 0;
}
``````

Thank you