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
When you're working with a word processing document and you press the del key, what happens?
Svetach [21]

The <DEL> or <Delete> key makes the first character AFTER the cursor
disappear, and everything after it then moves back one space to close up
the hole.

Example: 

If I have this in my document ...                          Most trees are green.

And my cursor is after the 'a', like this:                Most trees a|re green.

Now, if I hit the <delete> key, it deletes the
'r' after the cursor, and the hole closes up,
and the cursor stays where it is:                          Most trees a|e green.


5 0
2 years ago
Read 2 more answers
To remove unwanted parts from an image, select the image and then choose the<br> option
Volgvan

Answer:

You need to make use of the Brush tool for removing the unwanted part of an image.

Explanation:

Yes, it is the brush tool or the lasso tool that you can make use of. and you will find brush tools in all sorts of image processing software may it be the paint or Photoshop. It is common to both the raster-based and vector-based image processing software. And you can easily find it inside the tool section, and then make use of it to remove the unwanted parts from an image.

8 0
3 years ago
Interchanges of ideas in forums and internet news groups are functions of which domain?
Anarel [89]
I believe that the answer to the question provided above is that the  <span>Interchanges of ideas in forums and internet news groups are functions of the information domain.</span>
Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
5 0
3 years ago
PLEASE HELP!!!!!
Allushta [10]

Answer:

Insert

Explanation:

Insert

7 0
3 years ago
Read 2 more answers
When using the red / yellow / green method to present status of a project, yellow can mean which of the following?
olga nikolaevna [1]

Answer:

Happiness is one of the obvious ones however I was not given any of the following so I am unsure as to what my options were.

Explanation:

the color is bright and is usually be thought to be the color of the sun which could give us happiness after a rainy day

8 0
3 years ago
Other questions:
  • Which of the following cannot be created using Word software?
    15·1 answer
  • Matthew is running a study on the effects of room temperature on performance on an algebra test. One group takes the test in a r
    5·1 answer
  • Which of the following statements about the break statement is false? Group of answer choices Common uses of the break statement
    12·1 answer
  • For each 8-bit data frame the layer uses a generator polynomial G(x) = x4+x2+ x+1 to add redundant bits. What is the sequence of
    11·1 answer
  • Which of the following should you consider when choosing a file format?
    9·2 answers
  • Although your project has been accepted by the customer, the contract with the system vendor specifies that it will support the
    13·1 answer
  • Brainly app won't let me watch ads anymore. I search my question and there is no skip button to watch an ad it only makes me buy
    7·2 answers
  • Koi jinda hei kya hello​
    13·2 answers
  • How to give a brainiest on a question? if you teach me i will give brainiest
    7·2 answers
  • Can you exclude header rows from sort in excel?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!