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
True or False? A supervisory control and data acquisition (SCADA) device is a computer that controls motors, valves, and other d
Gekata [30.6K]

Answer:

The correct answer to the following question will be "True".

Explanation:

SCADA is a hardware and software elements program that permits industrial enterprises to:

  • Agricultural processes are regulated locally or globally.
  • The human-machine interaction program specifically interfaces with equipment such as cameras, switches, generators, motors and much more.
  • Track, store, and process the data in real-time.

Therefore, the given statement is true.

4 0
3 years ago
Which of the following statements are true about the Internet?
Arlecino [84]
1, 2, and 3 are true
6 0
3 years ago
Telecommunications is the transmission of voice and video as well as data and usually implies transmitting a longer distance tha
saul85 [17]

Answer:

The correct answer to the following question will be "True".

Explanation:

  • Telecommunication seems to be the transmitting by cable, antenna, optical or other electromagnetic networks of signs, commands, letters, words, texts, pictures, and sounds, or knowledge of any kind.
  • This happens when the use of technologies involves the information exchange between participants in the conversation.

Therefore, the given statement is true.

6 0
2 years ago
In linux, a(n) ____ is a data structure that stores all information (such as file permissions, ownership, and file type) about a
Galina-37 [17]
Hi,


Answer => <span>Inode


Good Lessons </span>
4 0
3 years ago
Cell division is called:
Blizzard [7]

Answer:

Mitosis

Explanation:

6 0
2 years ago
Other questions:
  • Cleo finds herself frequently searching for messages from particular senders or with specific subjects. What should she create
    5·1 answer
  • In addition to training on the products and on company policy, it does not make sense to be prepared to speak about your company
    6·2 answers
  • Instructions:Type the correct answer in the box. Spell all words correctly.
    14·2 answers
  • What is industry 4.0 -automation revolution-, what is your opinion about the direction this revolution is taking the industry in
    8·1 answer
  • We will use linear interpolation in a C program to estimate the population of NJ between the years of the census, which takes pl
    10·1 answer
  • Specifications that establish the compatibility of products and the ability to communicate in a network are called:
    10·1 answer
  • True or False? You should never move an injured person.<br> True<br> False
    6·1 answer
  • Explica el empleo de cuentas y contraseñas en archivos
    6·1 answer
  • Suppose that a particular algorithm has time complexity T(n) = 3 \times 2^nT(n)=3×2 ​n ​​ and that executing an implementation o
    14·1 answer
  • I want to start a debate about something
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!