C Program to print all Elements of array in reverse order using Pointers

This page has designed to provide C Program to print all Elements of array in reverse order using Pointers. For example: if we enter 5 integers into array as 34 67 29 17 78, then the below given C program will display Elements of array in reverse order using Pointers as 78 17 29 67 34. The below given C program will print all Elements of array in reverse order using Pointers. Kindly check out the program to print all Elements of array in reverse order using Pointers.

Program to Print all Elements of array in reverse order using Pointers



#include<stdio.h>

#include<conio.h>

#define SIZE 25

int main(){

int max, a, array[SIZE];

int *pointr;

clrscr();

ptr = &array[0];

printf("

Enter the size of array : ");

scanf("%d", &max);

printf("

Enter %d integers into array: ", size);

for (a = 0; a < max; ++a) {

scanf("%d", pointr);

++pointr;

}

pointr = &array[max - 1];

printf("

Elements of array in reverse order are : ");

for (a = max - 1; a >= 0; a--) {

printf("

Element %d is %d : ", a, *pointr);

--pointr;

}

getch();

} Sample Output: Enter the size of array : 5

Enter 5 integers into array: 34 67 29 17 78

Elements of array in reverse order are : 78 17 29 67 34

Related Popular Posts: