// apna program to find reverse of an array using dma

include

include

int main() {
int *p,i,j,n,sum=0,avg=0,temp;
printf(“Enter the number of elements to store:\n”);
scanf(“%d”,&n);

printf("Enter the elements to store:\n");


p=(int*)malloc(n*sizeof(int));

    for(i=0;i<n;i++){
    scanf("%d",(p+i));
    }

    for(i=0,j=n-1;i<n/2;i++,j--){
        temp=*(p+i);
        *(p+i)=*(p+j);
        *(p+j)=temp;
    }

    for(i=0;i<n;i++){
    printf("%d ",*(p+i));
    }

    printf("\n");

return 0;

}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *