#include <stdio.h>
int main()
{
        int test_no ,count=1,i,n,j;
        scanf("%d",&test_no);
        fflush(stdin);
        int arr1[test_no];
        for(i=0;i<test_no;i++)
        {
                scanf("%d",&n);
                printf("\n");
                int arr[n];
                for(j=0;j<n;j++)
                {
                        fflush(stdin);
                        scanf("%d",&arr[i]);
                }
                for(j=1;j<=n-1;j++)
                {
                        if(arr[j-1]>arr[j])
                        {
                                count++;
                        }
                }
                if(n==1)
                {
                        arr1[i]=1;
                }
                else
                {
                        arr1[i]=count;
                }
                count=1;
        }
        for(i=0;i<test_no;i++)
        {
                printf("%d\n",arr1[i]) ;
        }
        return 0;
}
This solution is to this problem.
I am not getting the desired output for the third case , it's giving me output as 3 or 4 depending on whether I place fflush(stdin) before scanf("%d",arr[i]) or after scanf("%d",arr[i]) , please tell the problem with this code .
 
     
    