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
You can run a macro by:
oee [108]

Selecting the button assigned

Using the shortcut Keys assigned

Explanation:

By clicking the assigned button one can run a macro and we can assign a short cut key to macro which we created.

So, the two options we can use to run a macro.

7 0
3 years ago
Why is it good to be a computer programmer?​
liubo4ka [24]

Answer:

It's your wish become other professions like doctor, engineer are also good. But in this profession you can make apps, websites and can do hacking. Which is are cool things to do. But every profession is best at it's profession.

Explanation:

If you like my answer than please mark me brainliest

5 0
2 years ago
Not everything is a success all of the time! So do you know which version of Windows was the least popular?
mario62 [17]

Answer:

windows xp

Explanation:

I think because it is not fast and don't play the games and programs which have higher requirements

7 0
3 years ago
Need the answer ASAP!!! I’ll mark brainliest if correct
san4es73 [151]

Answer:

update standerds

Explanation:

7 0
3 years ago
Drag the correct type of update to its definition.
Deffense [45]

Answer:

Base band : A list of radio frequencies

PRI : The chip that controls the radio frequency waves within a device

PRL: The connection between a mobile device and radio tower

Explanation:

Base-band is the range or band of frequencies. It contains a number of between upper and lower limit of the frequency. For example if the range of transmission of the signal is 2khz to 3khz. The frequencies between this range are called base band.

PRI is the chip that is used to control the different frequencies received at the device. This chip control the radio frequencies that are allowed to the devices. It is the short form of primary rate interface.

PRL is the list named as Preferred Roaming List. It has stored the information of the mobile devices that are connected to the mobile phone. This list is used while communicating between mobile device and tower.

8 0
3 years ago
Other questions:
  • An attribute whose value uniquely identifies an object is called a(n) _______.​
    15·1 answer
  • Imagine that one of your clients has complained to your manager that you have not responded quickly to his e-mails. Compose an e
    14·1 answer
  • 2. Suppose you want to write a method that prints a heading on a new output page, along with a page number that is 1 in the firs
    15·1 answer
  • To insert a column without using commands in any tabs, a user can _____ -click and then click insert column.
    6·2 answers
  • What is hyper transport
    10·1 answer
  • What Word features allow you to copy multiple paragraph formatting syles
    5·1 answer
  • This tag is used to change the appearance of your text on your web page
    8·1 answer
  • You are starting a small web hosting business and
    11·1 answer
  • PLEASE HELP WILL MARK BRAINLIEST
    8·2 answers
  • scheduling is approximated by predicting the next CPU burst with an exponential average of the measured lengths of previous CPU
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!