C Program to Print Array in Reverse Order Using Pointer

Write a C program to print array in reverse order using pointers. This C progr accepts an array from the user and prints it reverse order of elements using pointers and for loop construct in C programming language.

 C Program :
/* Aim: Write program to displayc elements of an array in reverse order using pointer to the  array */ 

#include <stdio.h>
int main() {
	int arr[100],*ip,n,i;
    
	printf("\n How many numbers to accept:- "); 
	scanf("%d",&n);
    
	for(i=0;i<n;i++){
		scanf("%d",&arr[i]);}
    
	printf("\n The integers of an array in reverse order are as follows: \n");
    
	for(ip=&arr[n-1];ip>=&arr[0];ip--){
		printf(" %d",*ip);}
}// End of the code 

/* output of above code:-

 How many numbers to accept:- 5

 The integers of an array in reverse order are as follows: 

 6 56 56 57 46
*/
 

Comments