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
Kevin is working in the Tasks folder of his Outlook account. Part of his computer screen is shown below.
klasskru [66]

Answer:

D

Explanation:

7 0
3 years ago
Who do we make games for?(single term)
Ket [755]

Answer:

Gamers

Explanation:

5 0
3 years ago
Read 2 more answers
Jennifer turns on her laptop and hears a series of beeps. What do they probably indicate?.
telo118 [61]

Answer:

Bad Ram or CPU/GPU Problems

Explanation:

It depends on the motherboard used in the type of PC you'd have to look up the number of beeps and the time spread out to figure out your certain issue.

3 0
2 years ago
An indication of delayed fuel ignition could be​
Sophie [7]

Answer:

The ignition delay in a diesel engine is defined as the time interval between the start of injection and the start of combustion. This delay period consists of (a) physical delay, wherein atomisation, vaporization and mixing of air fuel occur and (b) of chemical delay attributed to pre-combustion reactions. Physical and chemical delays occur simultaneously.

Hope This Helps!     Have A Nice Day!!

6 0
3 years ago
Kyle is running out of disk space on his hard drive on a Windows XP Professional system. He has installed and configured a third
Varvara68 [4.7K]

Answer:

The answer is "Disk utility".

Explanation:

It'll work well go over to Disk utility before updating the drivers like diskmgmt.msc throughout the Running box, or right-click Device icon, and pick Manage. Click Rescan Disks on the key decision-makers. It's not essential to reconnect until the machine recognizes the latest disc.

  • In each disc setup as storage properties is a reactive drive. Almost every dynamic disk is separated into quantities.
  • It is the season, spanned, and strip volume forms will be included.
5 0
3 years ago
Read 2 more answers
Other questions:
  • What is the answer to this?
    9·1 answer
  • Adam is evaluating the security of a web server before it goes live. He believes that an issue in the code allows an SQL injecti
    5·1 answer
  • Which option nukes your systemâall apps, programs, user files, user settingsâand presents a fresh installation of Windows?
    13·1 answer
  • A digital designer might do computer animation or video games true or false
    13·2 answers
  • It takes 2.5 yards of material to make a dress harleys clothing design estimates that they can produce 48 dresses each week.if t
    15·2 answers
  • What will you better be prepared for by learning about the animals you photograph
    11·1 answer
  • A customer comes into a grocery store and buys 8 items. Write a PYTHON program that prompts the user for the name of the item AN
    9·1 answer
  • Dose anyone know how to change username, grade level, and gender here? I have tried it in the change preferences and it says it
    8·2 answers
  • Hey should I get a r()blox gift card if so what amount 5 dollars 10 or 100
    14·1 answer
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!