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
kondaur [170]
3 years ago
11

Given an array of integers and the size of the array, write a function findDuplicate which prints the duplicate element from the

array. The array consists of all distinct integers except one which is repeated. Find and print the repeated number. If no duplicate is found, the function should print -1.
Computers and Technology
1 answer:
Jlenok [28]3 years ago
5 0

Answer:

#include <iostream>

using namespace std;

void findDuplicate(int arr[], int size) {

  for(int i = 0; i < size; ++i) {

      for(int j = i+1; j < size; ++j) {

          if(arr[j] == arr[i]) {

              cout << arr[j] << endl;

              return;

          }

      }

  }

  cout << -1 << endl;

}

int main() {

  int arr[] = {2, 3, 5, 6, 11, 20, 4, 8, 4, 9};

  findDuplicate(arr, 20);

  return 0;

}

Explanation:

You might be interested in
WILL GIVE BRAINLIEST!! 20 PNTS!!
kirill [66]

Answer:

B :)

Explanation:

.........

3 0
3 years ago
Read 2 more answers
Suppose you have a class called Child with an instance data value called weight and height. Then it has a method called doubleWe
alexira [117]

Answer:

Explanation:

The following code is written in Java. I recreated the entire Child class as described with the instance variables and the doubleWeight method. Then created the getter and setter methods for both the weight and height variables.

class Child {

   double weight, height;

   public double doubleWeight() {

       double superWeight = weight * height;

       return superWeight;

   }

   public double getWeight() {

       return weight;

   }

   public void setWeight(double weight) {

       this.weight = weight;

   }

   public double getHeight() {

       return height;

   }

   public void setHeight(double height) {

       this.height = height;

   }

}

7 0
3 years ago
Which best describes a paraphrase?
Anna11 [10]
To rewrite something , but in your own words
4 0
3 years ago
The steps for creating a newsletter are to _____.
lys-0071 [83]
Puting your ideas together every write has to do that and also gather true information, and making a intering story for your readers.
7 0
3 years ago
Read 2 more answers
Assume the Student and Employee classes each extend the Person class. The Student class overrides the getMoney method in the Per
SSSSS [86.1K]

Answer:

Person p1, p2, p3;

int m1, m2, m3;

p1 = new Person();

// assignment 1

m1 = p1.getMoney();

p2 = new Student();

// assignment 2

m2 = p2.getMoney();

p3 = new Employee();

// assignment 3

m3 = p3.getMoney();

//////////////////////////////////////////////////////////////////////////////////////////////

The reference to getMoney in assignment 3 is to the <em>Person</em> class.

Explanation:

Since Employee class didn't override Person class's getMoney() method, calling p3 with getMoney() will call Base class's (Person) getMoney() method.

6 0
3 years ago
Other questions:
  • Which of the following is a valid call for the generic method declared below? and why?
    9·2 answers
  • During the boot process, the computer performs a quick self diagnostic then loads the operating system into memory.... IS THIS T
    5·1 answer
  • What does the term hardware refer to?
    13·1 answer
  • Which part of project management involves determining the overall work? Breakdown Incomes Scope Time
    15·1 answer
  • A lookup field allows the user to select from a list of values when updating the contents of a field. true or false.
    11·1 answer
  • Internet is for everyone but it wont be if its users cannot protect their privacy and the confidentiality of transactions conduc
    6·1 answer
  • Can an iphone user see when an android user is typing
    10·2 answers
  • Someone talk to me please........
    5·2 answers
  • Define the term algorithm and describe how programmers use algorithms when designing a program.
    13·1 answer
  • Lena is completing her senior year of college and is living in an apartment with three friends. Her family has a subscription to
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!