#include #include #include /* Write a C program that reverses the order of the elements of an integer array, i.e., the first element becomes the last and vice versa, the second element becomes the last but one and vice versa, etc. Your program must do the following 4 things in order: * initialize an array of size 10 with random integers in the range 1-10 * print the array by calling a function that you defined * reverse the entries of the array in the main function * print the reversed array by calling the same print function */ #define N 10 int print_array(int a[], int length) { int i; for(i=0; i< length; i++) printf("%3d, ", a[i]); printf("\n"); } int main() { int a[N]; int i, temp; srand(time(NULL)); for(i=0; i<=N; i++) // initialize a[i]=rand()%10 +1; print_array(a, N); for(i=0; i< N/2; i++) // reverse the array in place using swaps { // swap two array entries temp=a[i]; a[i]=a[N-i-1]; a[N-i-1]=temp; } print_array(a, N); system("pause"); return 0; }