please could you answer this question on C++ The arrays list1 and list2 are iden
ID: 3664896 • Letter: P
Question
please could you answer this question on C++
The arrays list1 and list2 are identical if they have the same contents. Write a method that returns true if list1 and list2 are identical, using the following header: public static boolean equalArrays (int[] list1, int[] list2) Write a test program that prompts the user to enter two lists of integers and displays whether the two are identical. Here are the sample runs. Note that the first number in the input indicates the number of the elements in the list. Test1 Enter list1: 5 5 2 6 1 6 Enter list2: 5 2 5 6 6 1 Two lists are identical Test2 Enter list1: 5 2 5 6 1 6 Enter list2: 5 5 5 6 6 1 Two lists are not identical
Explanation / Answer
#include<iostream.h>
#include<conio.h>
int main();
{
int list1[array_size];
int list2[array_size];
}
cout<<“please enter elements for list1”;
cin>>list1;
for(int i=0;i<array_size;i++)
cout<<“please enter elements for list2”;
cin>>list2;
for(int j=0;j<array_size;j++)
if(list1[0]==list2[0]&&list1[1]==list2[1]&&list1[2]==list2[2]&&l
ist1[3]==list2[3]&&list1[4]==list2[4]&&list1[5]==list2[5])
{
cout<<“two lists are identical”;
}
else
{
cout<<“two lists are not identical”;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.