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]
4 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]4 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]4 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
A plan to budget time for studying and activities is referred to as a study routine. study habits. study skills. a study schedul
vesna_86 [32]

Answer:

A study routine

Explanation:

6 0
3 years ago
Read 2 more answers
One reason for using social media is to develop social and professional contacts. True or false?
xxMikexx [17]
I would say this answer is true.
7 0
3 years ago
Read 2 more answers
For a windows labtop what is the best way to save power when the computer will not be used for an extended period
rjkz [21]

Answer:

Put the Computer to sleep or hibernate Mood

Explanation:

The best way to save power when the computer will not be use for an extended period is to put the computer to sleep or hibernate mood depending on the OS (Operating System) you are using.

For instance in windows 10, all you need do is to Press the Windows key on the keyboard, then click on Sleep.

3 0
3 years ago
.To remove data from a table we use the DELETE verb? (true/false)
Andrew [12]

Answer:

The correct answer for the given question is "true".

Explanation:

Yes delete is a verb in a database table  because it perform the action it means it will delete the data or record from a database table .The SQL query of delete is

Delete from tablename ;

For example :delete name from student;

In this query name will deleted from student table this action will be performed by delete query so we conclude that delete is a verb.

5 0
3 years ago
Jason works as a Help Desk Technician for uCertify Inc. The company has a Microsoft Windows XP-based network. Jason wants to vie
WINSTONCH [101]

Answer:

ipconfig

Explanation:

ipconfig (short for <em>internet protocol configuration</em>) is a command line tool used for determining the network connection configuration of a computer. Some of these configuration information are;

i. the IP address of the computer

ii. default gateway address

iii. subnet mask

iv. Media Access Control (MAC) address.

6 0
3 years ago
Other questions:
  • All customers are on a Customer Community License. Universal Containers needs to grant a subset of their customers, known as aff
    9·1 answer
  • If a disk drive has 8 surfaces and there are 1024 tracks per surface with 256 sectors per track and 512 bytes/sector. What is th
    9·1 answer
  • What is the best web browser to use?
    9·2 answers
  • How to transfer photos from iphone to iphone?
    14·2 answers
  • What are the basic components of a Production System?
    6·1 answer
  • George writes code for word processing applications. He is looking for a new job opportunity. What position should George look f
    5·2 answers
  • When a CPU executes instructions as it converts input into output, it does so with
    12·1 answer
  • Website hosting servers have their own unique IP address, what does this address consist of?
    8·1 answer
  • Matlab In this assignment you will write a function that will calculate parallel resistance for up to 10 parallel resistors. Cal
    15·1 answer
  • Who knows ro blox and plays funky friday??? :] cause i do and its fun
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!