just writing and testing the code using arrays,
int main()
{ int i,n;
int arr[14];
printf("\nEnter the array ",n);
scanf("%d",&n);
int lastindex = n-1;
int *l;
l = &lastindex;
for(i = 0;i<n;i++)
{
scanf("%d",&arr[i]);
}
for(i = 0;i<n;i++)
printf("\n%d\n",arr[i]);
printf("%d",*l);
//arr[i] = lastindex + 2;
//printf("\n%d",arr[i]);
if(arr[lastindex[arr]] < lastindex)
{
printf("\n %d",arr[lastindex[arr]]);
printf("\nright");
}
else
{ printf("\n%d",lastindex);
printf("wrong");
}
}
//output
Enter the array 5
5
4
3
2
1
5
4
3
2
1
4
4 wrong
arr[lastindex[arr]]
lastindex[arr] will be 4
arr[4]= 1
1 < 4 is true so it has to print right,but its printing wrong
whats the wrong in the code