#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
if (left >= right)
return;
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
func(arr, left + 1, right - 1);
}
void printArray(int arr[], int size)
{
for (int i = 0; i < size; i++)
cout << arr << " ";
}
int main()
{
int arr[] = {1,2,3,4};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}
a) 1 2 3 4
b) 4 3 2 1
c) 1 4 2 3
d) 4 1 2 3
What will be the output of the following code ?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What will be the output of the following code ?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!