the input depicts no of tests followed by size of input array followed by the array and the output either gives -1 or the square of the largest prime in the given array. I am providing the code and the expected and actual output along with sample standard input used.
standard input:
3
5
1 4 6 8 10
3
2 2 9
2
156 13
expected output | getting
-1 -1
4 4
169 -1
#include <stdio.h>
int main(){
int test,size;
int i,j;
scanf("%dn",&test);
while(test>=1){
scanf("%dn",&size);
int data[size],factors=0,max=0;
for(i=0;i<size;i++){
scanf("%d ",&data[i]);
for(j=1;j<=data[i];j++){
if(data[i]%j==0){
factors+=1;
}
}
if((factors==2) && (data[i]>max)){
max=data[i];
}
}
if(max>=2){
printf("%dn",max*max);
}else{
printf("%dn",-1);
}
max=0;
test-=1;
}
}
