C++ 1. Two arrays, list1 and list2 are identical if they have the same contents.
ID: 3908339 • Letter: C
Question
C++ 1. Two arrays, list1 and list2 are identical if they have the same contents. Write a function that returns true if list1 and list2 are identical, and false if not.
DO NOT USE BOOL. Use a for loop. This is what I have so far, I need prototypes and a working program.
#include <iostream>
using namespace std;
int main()
{
int list1[]= {1,2,3,4,5,6,7,8,9};
int list2[]= {1,2,3,4,5,6,7,8,9};
cout<<"Elements in List-1 are: "<<endl;
for(int i=0;i<9;i++)
cout<<list1[i]<<" ";
cout<<endl<<endl;
cout<<"Elements in List-2 are: "<<endl;
for(int i=0;i<9;i++)
cout<<list2[i]<<" ";
cout<<endl<<endl;
if(areIdentical(list1, list2))
cout<<"List-1 and List-2 are identical."<<endl;
else
cout<<"List-1 and List-2 are not identical."<<endl;
}
{
for(int i=0;i<n;i++)
{
if(list1[i] != list2[i])
return false;
}
return true;
}
2. Write a program that takes a string of someone's name and prints it out last name first. Your program must use pointers, not array subscripts. You may use the available string
manipulation functions if you find an opportunity.
Example:
"George Washington"
" Washington, George"
Explanation / Answer
#include using namespace std; int areIdentical(int l1[], int l2[], int size) { for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.