We have the best collection of the Reversal Array Operation MCQs and answer with FREE PDF. These Reversal Array Operation MCQs will help you to prepare for any competitive exams like: BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly.

## Reversal Array Operation MCQs

**1. When array reversal and rotation is applied to the same array then the output produced will also be the same every time.**

a) true

b) false

**Answer: **false

**2. Which of the following is the predefined function for array reversal in C++?**

a) reverse()

b) arr_reverse()

c) array_reverse()

d) rev()

**Answer: **reverse()

**3. Which of the following is the predefined function for array reversal in javascript?**

a) reverse()

b) arr_reverse()

c) array_reverse()

d) rev()

**Answer: **reverse()

**4. Predefined function reverse() in C++ is available under which header file?**

a) math

b) stdio

c) stdlib

d) algorithm

**Answer: **algorithm

**5. What will be the resulting array after reversing arr[]={3,5,4,2}?**

a) 2,3,5,4

b) 4,2,3,5

c) 5,4,2,3

d) 2,4,5,3

**Answer: **2,4,5,3

**6. How many swaps are required for reversing an array having n elements where n is an odd number?**

a) (n-1) / 2

b) n/2

c) (n/2) – 1

d) (n+1)/2

**Answer: **(n-1) / 2

**7. How many swaps are required for reversing an array having n elements where n is an even number?**

a) (n-1) / 2

b) n/2

c) (n/2) – 1

d) (n+1)/2

**Answer: **n/2

**8. What will be the output of the following code?**

```
#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}
}
void printArray(int arr[], int size)
{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}
int main()
{
int arr[] = {1,4,3,5};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}
```

a) 5 1 4 3

b) 3 5 1 4

c) 5 3 4 1

d) error

**Answer: **5 3 4 1

**9. What will be the time complexity of the following code?**

```
#include <bits/stdc++.h>
using namespace std;
void func(int arr[], int left, int right)
{
while (left < right)
{
int temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
left++;
right--;
}
}
void printArray(int arr[], int size)
{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
}
int main()
{
int arr[] = {1,4,3,5};
int n = sizeof(arr) / sizeof(arr[0]);
func(arr, 0, n-1);
printArray(arr, n);
return 0;
}
```

a) O(n)

b) O(log n)

c) O(1)

d) O(n log n)

**Answer: **O(n)

**10. What will be the output of the following code?**

```
#include <bits/stdc++.h>
using namespace std;
void func(int a[], int n, int k)
{
if (k <= n)
{
for (int i = 0; i < k/2; i++)
swap(a[i], a[k-i-1]);
}
}
int main()
{
int a[] = {1, 2, 3, 4, 5};
int n = sizeof(a) / sizeof(int), k = 3;
func(a, n, k);
for (int i = 0; i < n; ++i)
cout << a[i]<<" ";
return 0;
}
```

a) 3 2 1 4 5

b) 5 4 3 2 1

c) 1 2 5 4 3

d) error

**Answer: **3 2 1 4 5