You are given an int variable k ,an int array zipcodeList that has been declared
ID: 3609818 • Letter: Y
Question
You are given an int variable k ,an int array zipcodeList that has been declared andinitialized, an int variable nZips that contains the number of elementsin zipcodeList , and a bool variable duplicates .Write some code that assigns true to duplicates if there are two adjacent elements inthe array that have the same value, and that assigns false to duplicates otherwise.
Use only k , zipcodeList, nZips , and duplicates.
Instructor's notes: Set duplicates to false tobegin with. Then search the array from the first element to thesecond-to-last element. Compare the value in the element denoted ink with that at k+1, if theycontain the same value then set duplicates totrue.
Explanation / Answer
/* Use this function in your code This function returns True if there are duplicate elements adjacentto each other otherwise it returns false */ bool checkDuplicates(int current, int zipcodeList[], intnZips){ while(currentRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.