How to use C program to write the following code Write a fun
How to use C program to write the following code
Write a function which is passed an int A [] of positive integers and A\'s length. The function reverses A. For example, if before the function, A [] is {10, 20, 30, 40, 50}. after the function, A [] is {50, 40, 30, 20, 10}. Do not use the [] operator in the body of the function.Solution
// C code reverse array
 #include <stdio.h>
 
 // function to reverse array
 void reverse(int *array, int size)
 {
 int j = size - 1; // j will Point to last Element
 int i = 0; // i will be pointing to first element
 
 while (i < j)
 {
     // swapping elements
 int temp = *(array+i);
 *(array+i) = *(array+j);
 *(array+j) = temp;
 i++; // increment i
 j--; // decrement j
 }
 }
int main()
 {
 int i;
 int array[] = {10,20,30,40,50};
 int size = 5;
// call reverse function
 reverse(array,size);
 
 //Print out the Result of Insertion
 printf(\"\ Array after reversing: \");
 for (i = 0; i < size; i++)
 {
 printf(\"%d \", *(array+i));
 }
    
 printf(\"\ \");
 return 0;
 }
![How to use C program to write the following code Write a function which is passed an int A [] of positive integers and A\'s length. The function reverses A. For How to use C program to write the following code Write a function which is passed an int A [] of positive integers and A\'s length. The function reverses A. For](/WebImages/28/how-to-use-c-program-to-write-the-following-code-write-a-fun-1075013-1761563682-0.webp)
