Help me in solving RATINGINPRAC problem

My issue

hello everyone !
I was solving a question of array ,I am new to code and and seen that in many contest the question related to array has been asked so can you guys help me solving this question in this question I am getting extra yes instead of no and at the end of the problem also I am getting one yes, thankyou for your supports.

My code

#include <iostream>
using namespace std;
void slope()
{
    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] < a[i - 1])
        {
            cout<<"NO"<<endl;
            
        }

         
    }
cout<<"yes "<<endl;
}

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t > 0)
	{
	    slope();
	    t--;
	   
	}

	return 0;
}

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

@dubeyaayush
U have made logical mistakes.
I have corrected in your code.
Hope u will get it.

#include <iostream>
using namespace std;
void slope()
{
    int n;
    cin>>n;
    int a[n];
    
    for(int i = 0; i <n;i++)
    {
        cin >> a[i];
        
    }
    int f=0;
    for(int i = 1; i < n ;i++)
    {
        if(a[i] < a[i - 1])
        {
            f=1;
            cout<<"NO"<<endl;
            break;
            
        }

         
    }
    if(f!=1)
    {
cout<<"yes "<<endl;
}
}

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    slope();
	    
	   
	}

	return 0;
}

thank you !