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
The RAM memory of a computer contains the volatile memory, which includes
lara31 [8.8K]

The RAM memory of a computer contains the volatile memory, which includes; Websites recently visited

<h3>Random Access Memory(RAM)</h3>

Random access memory (RAM) is defined as a computer's short-term memory that it utilizes to handle all active tasks and applications.

Now, no single program, file, game, or stream would work without a RAM. Thus, RAM is a temporary storage that goes away when we shut down the computer.

Examples of things that RAM store from the options given is only websites visited recently.

Read more about Random Access Memory at; brainly.com/question/86807

3 0
3 years ago
Java allows you to declare methods with the same name in a class. this is called
Tanzania [10]
Polymorphism. Understand: you can have the same names, but the arguments HAVE to be different so that in the bytecode the signatures are unique.
8 0
3 years ago
Decision-making problems that can be stated as a collection of desired goals are known as what type of problem? A goal programmi
Vera_Pavlovna [14]

Answer:

True. A goal programming problem

Explanation:

Goal programming is an optimisation technique to solve problems with multiplicity of objectives, which are generally in commensurable and they often conflict each other in a decision making horizon.In a certain programming environment, optimisation of a set of objectives is involved there in the decision situation. Here, instead of optimising them directly, achievement of the assigned target values called aspiration levels of them is considered. In goal programming method, the unwanted deviations (under and / or over) from the aspired levels are minimised in the goal achievement function (objective function) to reach a satisfactory solution in a crisp decision environment

4 0
3 years ago
Do you think Google has an unfair advantage as a social media marketing platform
Mama L [17]
My personal thoughts are Google doesn't have any advantage, they simply offer more than other social media platforms.
7 0
3 years ago
Read 2 more answers
What phenomenon enables us to see animation in images
Ivahew [28]
An optical illusion, called persistence of vision allows humans to see animation. Our brains can process 10 to 12 images per second.
8 0
3 years ago
Other questions:
  • To recover a deleted document, what would you choose in the Info window?
    14·1 answer
  • Using a database of precomputed hashes from sequentially calculated passwords called a(n) __________, an attacker can simply loo
    14·1 answer
  • In Windows Vista, which location contains the Printer link?
    8·2 answers
  • What is constructive criticism?
    9·1 answer
  • Strong emotions can interfere with your ability to
    15·1 answer
  • What is the missing line of code?
    10·2 answers
  • To date, what has most propelled the digital revolution?
    10·1 answer
  • What are source data entry devices​
    13·1 answer
  • Which of the following statements best illustrates how value was created for eggs? when a farmer sells a chicken who is no longe
    9·1 answer
  • Which one causes concerns for institutions or businesses when they are collected stores and they aren’t secured properly?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!