Array comparison

If an array arr contain n element,then write a program to check if arr[0]=arr[n-1],arr[1]=arr[n-2] and so on.
#include


#include

#define max 20

void main (void)

{

clrscr();

int *fp,arr[max],i,n;

printf("Enter a series of numbers(MAX lenght is 20):");

for(i=0;i<20;i++)

{

printf("\nEnter the %d element",i+1);

scanf("%d",&arr[i]);

}

fp=&arr[19];



for(i=0;i<10;i++)

{

if(arr[i]==*fp)

printf("\nMatch");

else

printf("\nA mismatch");

fp--;

}

getch();

}

Comments

Popular posts from this blog

Tip of the Day # 13

Governor Generals of Pakistan