23.Reverse Array
#include <stdio.h>
void reverseArr(int arr[], int b);
int main()
{
int arr[] = {1, 2, 3, 4, 5};
int n = 5;
reverseArr(arr, n);
for(int i=0; i<5; i++)
printf("%d\n",arr[i]);
return 0;
}
void reverseArr(int arr[0], int n)
{
for (int i = 0; i < n/2; i++)
{
int temp;
temp = arr[i];
arr[i] = arr[n - i - 1];
arr[n-i-1]=temp;
}
}
Comments
Post a Comment