You are on page 1of 2

Review question 1

#include <iostream>
using namespace std;

const int size1=10;


const int size2=15;

void readArray (int array[],int size)


{
cout<<"Enter numbers to place in the array: "<<endl;
for (int i=0;i<size;i++)
cin>>array[i];
}

void printArray(int array1[],int array2[],int size1,int size2)


{
cout<<"The no. that appears twice = ";
for(int i=0;i<size1;i++)
{
int count=0;
for(int j=0;j<size2;j++)
{
if (array1[i]==array2[j])
count++;
}
if(count==2)
cout<<array1[i]<<", ";
}

int main ()
{
int array1[size1];
int array2[size2];

readArray (array1,size1);
readArray (array2,size2);

printArray(array1,array2,size1,size2);

cout<<endl;
system("PAUSE");
return 0;
}

You might also like