Valeo Interview Question

Write a program to check if the given array is palindrome or not ??

Interview Answers

Anonymous

Oct 13, 2017

int CheckPal (int *arr , int size) { int i=0,j=size-1,Pal=1; while (i<=j) { if (arr[i]==arr[j]); else { Pal =0; break; } ++i;--j; } if (Pal) return 1; else return 0; }

Anonymous

Nov 19, 2020

int main() { int flag=-1; int ar[5]={4,1,5,1,4}; for(int forword=0,bw=4;forword=0;forword++,bw--){ if(ar[forword]==ar[bw]){flag=1;} else{flag=-1;break;} //for(int bw=4;bw>=0;bw--) } flag==1?printf("ok"):printf("not ok"); }