C Progrma to reverse array using pointer
Simple C program to reverse using pointer:
/* C program to reverse array using pointer */ #include<stdio.h> int main() { int i,j,*ptr; int arr[]={12,43,11,87,34,87,32}; int n=sizeof(arr)/sizeof(arr[0]); printf("Array is: \n"); /* You can print array using arr[i] */ for(i=0;i<n;i++) { printf("%d ",*(arr+i)); } ptr=arr; i=0; j=n-1; while(i<j) { int temp=*(ptr+i); *(ptr+i)=*(arr+j); *(arr+j)=temp; i++;j--; } printf("\nReverse array is :\n"); /* Can print array using arr[i] or *(ptr+i) */ for(i=0;i<n;i++) { printf("%d ",*(arr+i)); } return 0; }