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
What does perseverance mean?
Dmitriy789 [7]
Ansewer is C a willingness to keep trying
7 0
3 years ago
Read 2 more answers
What are the five types of alignment in Word?
Basile [38]
There are four types of alignment in word.
Left-aligned text
Right-aligned text
Center-aligned text
Justified text
6 0
4 years ago
Read 2 more answers
1. ¿Cuál es el papel de la voz en la radio?
MrRa [10]

Answer:

Locutor

Explanation:

Asi se llama el papel de la voz en la radio

Espero y te sirva :)

5 0
4 years ago
What does DKIM stand for?
zheka24 [161]
Domain Keys Identified Mail is the answer:)
4 0
3 years ago
Read 2 more answers
Implementing content filtering and intrusion detection/intrusion prevention systems at the Internet ingress/egress as well as di
olya-2409 [2.1K]

the correct answer is:

d. clicking on unknown e-mail attachment and files.

5 0
3 years ago
Other questions:
  • python (Financial application: compute the future investment value) Write a function that computes a future investment value at
    5·1 answer
  • Write a function called median, that takes as parameter a full, sorted array of doubles and returns the median of the list. For
    15·1 answer
  • Given the following code fragment, how many times does the loop body execute? int laps = 50; int myNum = 1; do { myNum = myNum +
    9·1 answer
  • What can be done in order to secure a WLAN/wireless access point?
    12·1 answer
  • Which component is a part of the CPU of a computer
    12·2 answers
  • A user has called the company help desk to inform them that their Wi-Fi enabled mobile device has been stolen. A support ticket
    13·1 answer
  • My computer just fried anybody know why it did that?
    14·2 answers
  • List safety conditions when downloading shareware, free free where, or public domain software
    14·1 answer
  • Look out for users with this photo.
    15·2 answers
  • Need help ASAP <br><br> Thankss + BRAINLIST only for correct answers
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!