#include <iostream>using namespace std;int main() {int size1, size2;// Taking input size of first arraycout << "Enter size of first array: ";cin >> size1;int arr1[size1];cout << "Enter elements of first array:\n";for (int i = 0; i < size1; i++) {cin >> arr1[i];}// Taking input size of second arraycout << "Enter size of second array: ";cin >> size2;int arr2[size2];cout << "Enter elements of second array:\n";for (int i = 0; i < size2; i++) {cin >> arr2[i];}// To store common elementsint commonElements[size1 < size2 ? size1 : size2];int count = 0;// Check each element in arr1 against arr2for (int i = 0; i < size1; i++) {bool found = false;for (int j = 0; j < size2; j++) {if (arr1[i] == arr2[j]) {found = true;break;}}if (found) {// Check for duplicatesbool alreadyExists = false;for (int k = 0; k < count; k++) {if (commonElements[k] == arr1[i]) {alreadyExists = true;break;}}if (!alreadyExists) {commonElements[count] = arr1[i];count++;}}}// Print common elementscout << "Common elements: ";for (int i = 0; i < count; i++) {cout << commonElements[i] << " ";}cout << endl;// Print total countcout << "Total number of common elements: " << count << endl;return 0;}