Home / Programs / Write a program to print the elements of array in reverse order.
Programming Example

Write a program to print the elements of array in reverse order.

👁 944 Views
💻 Practical Program
📘 Step by Step Learning
Write a program to print the elements of array in reverse order.

Program Code

#include <stdio.h>
int main(void)
{
	int a[] = {10, 12, 6, 7, 2};
	int i, *p;
	p=a+4;
	for(i=0; i<5; i++)
		printf("%d\n", p[-i]);
	return 0;
}


Output

2
7
6
12
10


Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.