Write a user defined function Reverse(int A[],int n) which accepts an integer array and its size as arguments(parameters) and reverse the array. Example : if the array is 10,20,30,40,50 then reversed array is 50,40,30,20,10
Answers
Answered by
9
Explanation:
The user defined function Reverse(int A[],int n) which accepts an integer array and its size as arguments(parameters) and reverse the array is as follows:
void Reverse( int A[ ] , int n)
{
int temp;
for(int i=0;i<n/2;i++)
{
temp=A[i];
A[i]=A[n-1-i];
A[n-1-i]=temp;
}
} This is the simple solution of the defined function reverse.
The reversed form is just like the altered arrangemnt of the array. The example is like if the array is 10,20,30,40,50 then reversed array is 50,40,30,20,10.
Similar questions