/*Program to reverse array elements*/
#include<stdio.h>
void main() {
int A[10], i, temp;
printf("\nEnter the ten numbers:\n");
for (i = 0; i < 10; i++)
scanf("%d", &A[i]);
for (i = 0; i < 5; i++) {
temp = A[i];
A[i] = A[9 - i];
A[9 - i] = temp;
}
printf("\nReverse order is:\n");
for (i = 0; i < 10; i++)
printf("\n%d", A[i]);
}
WHAT'S NEW?
Loading...
The algorithm to reverse an array is similar to the algorithm of reversing a string. Actually, a c string is also an array of characters.
ReplyDelete