Write a function called reversearray that takes two argument
Write a function called reverse_array that takes two arguments: a one-dimensional array of type double and the size of that array; and modifies this array by rearranging it in reverse order. For example, suppose the array argument originally contains: 4 9 -1 17 0 25 Then after calling reverse_array, the array should now contain: 25 0 17 -1 9 4 Write a program that first reads at most 30 numbers of type double from the user (the user will type character quit when finished), and stores these values in an array in the same order that they were entered by the user. Your program should then call the function reverse_array with this array as an argument, and finally displays the new contents of the array to the screen, 5 values per line. Sample Input/Output: (the user\'s input is shown in bold) Please enter at most 30 numbers; type quit when finished. 1 396 470 -9 -1 9180 -5011 0 2 -275 13 216 15 -7 quit The array in reverse order (5 values per line) is: -7 15 216 13 -275 2 0 -5011 9180 -1 -9 470 1396
Solution
void reverse(double a[], int n)
{
int i,j,temp;
printf(\"reverse of 1-D Array\ \");
for(i=0;j=n-1;i<=2;i++,j--)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
for(i=0;i<n;i++)
{
printf(\"%d\\t\",a[i]);
}
}
