1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Musya8 [376]
3 years ago
10

You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, an int variable nZips

that contains the number of elements in zipcodeList, and a bool variable duplicates. Write some code that assigns true to duplicates if any two elements in the array have the same value, and that assigns false to duplicates otherwise. Use only j, k, zipcodeList, nZips, and duplicates.
Computers and Technology
2 answers:
irina [24]3 years ago
5 0

Answer:

You cant use j =0… you have to use j = k+1, otherwise j =1 and k =1 will match up and be equal when really its comparing the exact same line to itself.

Explanation:

The solution will be as follows:

duplicates = false

for (k = 0; k < nZips; k++){

   for (j = k+ 1 ; j < nZips ; j++){

     if (zipcodeList [k] ==zipcodeList[j]){

          duplicates =true

           break;

              }

        }

}

dmitriy555 [2]3 years ago
3 0

Answer:

The c++ program for the scenario is given below.

#include <iostream>

using namespace std;

int main() {    

   int i,j, nZips, zipcodeList[nZips];

   bool duplicates;        

   cout<<"This program checks if duplicate values exist in the array." <<endl;    

   cout<<"Enter the number of integers to be inserted in the array."<<endl;

   cin>>nZips;    

   cout<<"Enter the integers to be inserted in the array."<<endl;    

   for(i=0; i<nZips; i++)

   {

       cin>>zipcodeList[i];

   }    

   for(i=0; i<nZips; i++)

   {

       for(j=0; j<nZips; j++)

       {

           if(i != j)

           {

               if(zipcodeList[i] == zipcodeList[j])

               {

                   duplicates = true;

                   cout<<"The value of duplicates variable is true meaning "<<duplicates<<endl;

                   break;

               }

               else

                   duplicates = false;

           }

       }

       

       if(duplicates == true)

               break;

}    

   if(duplicates == false)

       cout<<"The value of duplicates variable is false meaning "<<duplicates<<endl;    

   return 0;

}  

OUTPUT

This program checks if duplicate values exist in the array.

Enter the number of integers to be inserted in the array.

7

Enter the integers to be inserted in the array.

1234

2345

1234

5678

9087

6554

4560

3456

6789

The value of duplicates variable is true meaning 1  

Explanation:

The variables mentioned in the question are used as required. There is no logic applied to validate user input. It is assumed that user inputs only valid values.

This program is designed to check whether duplicate values are present in the array. The boolean variable duplicates is assigned value true or false depending on the presence of duplicate values.

The user is prompted the number of values to be put in the array along with those values.

Once the array is filled, the array is checked for identical values. If any identical value is present, the value of duplicates variable is assigned to true and the loop is discontinued.

If no identical values are present, the loop completes and duplicates variables is assigned the value of false.

In either case, the value of the duplicates variable is displayed.

You might be interested in
In database systems, the dbms enforces rules about which user can perform which action when. The rules are known as ________.
saw5 [17]

I guess the correct answer is concurrency control

Cοncurrеncy cοntrοl is a databasе managеmеnt systеms (DBMS) cοncеpt that is usеd tο addrеss cοnflicts with thе simultanеοus accеssing οr altеring οf data that can οccur with a multi-usеr systеm.

In database systems, the DBMS enforces rules about which user can perform which action when. The rules are known as concurrency control.

6 0
3 years ago
What can a method do with a checked exception? Check the exception or ignore it. Return the exception to the sender or handle it
Serggg [28]

Answer:

Handle the exception in a catch block or throw the exception to the method that called this method.

Explanation:

The try and catch statements occur in pairs. The try statement allows the user to define a block of code to be tested for errors while it is being executed.

The catch statement allows the user to define a block of code to be executed, if an error occurs in the try block.

If an exception is checked by a method, the method either handles the exception in a catch block or throw the exception to the method calling it.

8 0
2 years ago
Read 2 more answers
QUESTION 9 / 10
In-s [12.5K]

Answer:

The answer is C. the bank will cancel your credit card.

Explanation:

5 0
3 years ago
Which version of Windows 10 is better?
IrinaVladis [17]

Answer:

Windows 10 has diverse editions and your purpose of use.

Explanation:

Windows 10 Home edition is consumer-focused desktop edition and good for home use alone.

Windows 10 Mobile edition is designed to meet and deliver the best user experience on smaller, mobile, touch-centric devices like smartphones and small tablets.

Windows 10 Pro is also a desktop edition for PCs, tablets. It has upon both it, the familiar and innovative features of Windows 10 Home, it has many extra features designed to meet the various needs of small businesses.

Windows 10 Enterprise builds on Windows 10 Pro, adding advanced features designed to meet the demands of medium and large sized organizations.

This  also supports the broadest a very wide range of options for operating system deployment but on a LIVE server or a Test server and equally have a comprehensive device and app management added.

8 0
2 years ago
Differentiate the term, "bundling," as applied to a Mac/Apple computer and a PC.
saw5 [17]

Answer:

Mac comes with the up (or is bundled with) the up-to-date OS where with windows there are multiple flavors to choose from.

Explanation:

Sorry if its wrong

8 0
3 years ago
Other questions:
  • Which player type focuses on level progression?
    13·1 answer
  • A USB is used for _________.[ pick the best answer that makes sense]
    14·2 answers
  • What kind of app or technology would you like to create?  Why ? <br><br><br>​
    11·1 answer
  • How do you know when a spreadsheet object is active in a Word document?      A. The Ribbon is minimized. B. The Excel Formula ba
    10·2 answers
  • Which method is the quickest for removing multiple different indent types applied to a paragraph
    11·2 answers
  • Rewritable (write, erase, write again) is known as _______.
    7·1 answer
  • As marketing manager, you need to have ( blank) skills and (blank) skills.
    11·1 answer
  • Help!!
    15·1 answer
  • Which of the following is not a group of energy sources?
    7·2 answers
  • 8. Which of the following is an output device
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!