why am i getting wrong answer ? Ranbow

#include<stdio.h>
#include<malloc.h>
void input(int *ar, int n){
int i;
for(i=0;i<n;i++){
scanf("%d",&ar[i]);
}
}
int checkRanbow(int *ar, int n){
int i = 0;
while(i<n){
if(ar[i]!=ar[n] || (ar[i+1]-ar[i])>1 || (ar[n-1]-ar[n])>1)
return 0;
i++;
n–;
}
return 1;
}

void display(int *res, int n){
	int i;
	for(i = 0; i < n; i++){
		if(res[i] == 1)
			printf("yes\n");
		else
			printf("no\n");
	}
}
int main(){
	int *ar,n,t,*res,i=0;
	scanf("%d",&t);
	res = (int*)malloc(t*sizeof(int));
	while(t--){
		scanf("%d",&n);
		ar = (int*)malloc(n*sizeof(int));
		input(ar,n);
		res[i++] = checkRanbow(ar,n-1);
	}
	display(res,i);
}

Where is your check for "Rainbow array has numbers only between [1,7]" ?

Insert one more check condition for each element if(arr[i]<=0 && arr[i]>7) printf(“no”);
And also u can initially check if(arr[n]/2 != 7) printf(“no”); Rest ur program is gd…

You Have to print “no” if the middle element is not 7