In this program, we are going to share how to reverse an array using C programming language. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to reverse an array with the output.
Copy the below C program and execute it with the help of Turbo C compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <stdio.h> int main() { int n, c, d, a[100], b[100]; printf("Enter the number of elements in an array\n"); scanf("%d", &n); printf("Enter the array elements\n"); for (c = 0; c < n ; c++) scanf("%d", &a[c]); for (c = n - 1, d = 0; c >= 0; c--, d++) b[d] = a[c]; for (c = 0; c < n; c++) a[c] = b[c]; printf("Reverse array is\n"); for (c = 0; c < n; c++) printf("%d\n", a[c]); return 0; } |
Enter the number of elements in an array
3
Enter the array elements
10
15
20
Reverse array is
20
15
10
Liked this program? Do Like & share with your friends.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: C Program to Reverse an Array, c program to reverse an array using for loop, c program to reverse an array using function, c program to reverse an array using pointers, c program to reverse the elements of an array, how to reverse an array in c, Program to reverse an array in C, reverse array in c# using for loop, Write a program to reverse an array or string