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 ______ Works on a single variable or constant. *​
lora16 [44]

Answer:

man

Explanation:

6 0
3 years ago
What are the data types used in C programming with examples
Zepler [3.9K]
I don’t really understand what you are trying to ask. Try posting a picture along with your question
5 0
3 years ago
Select the correct answer.
Softa [21]

Answer:

D. smart phone

explanation;

a. what the heck is a radio going to do?

b. an HD television? is his job watching movies?

d. he already has a form of communication he uses, he needs something that can to both things at the same time

c. a smart phone can do everything he needs to do, likely faster than a landline phone or laptop.

5 0
2 years ago
Write a declaration of a variable named count that can be used to hold numbers like 90000 and -1 and -406.
Andreyy89
Which language? In Java it would simply be:

int count;
7 0
3 years ago
After receiving a call from an executive, a technician walks into a meeting room to find that the projector is not showing the s
qwelly [4]

Answer:

Answer is c) Verify the vga cable is connected

Explanation:

No video signal means that the projector is not receiving any data from the laptop. Verifying the cable connection should be the first test you should do.

If the cable is properly connected and the projector keeps showing that error then you can move on and perform additional tests, but the first requirement for establishing a connection is that the cable is properly connected.

4 0
3 years ago
Other questions:
  • What is the name of the program that takes high-level code and transforms it into machine-level code?
    8·1 answer
  • If you think the user might enter 24.9, you should create a float variable. true or false
    9·1 answer
  • Write the definition of a function half , which receives an integer parameter and returns an integer that is half the value of t
    7·1 answer
  • Print a countdown from n to 1 The function below takes one parameter: an integer (begin). Complete the function so that it print
    8·1 answer
  • What is not a common purpose for a research report?
    5·2 answers
  • A large software development company employs 100 computer programmers. Of them, 45 areproficient in Java, 30 in C, 20 in Python,
    9·1 answer
  • Why does dew form on grass overnight
    7·1 answer
  • Power point presentation make use of pages known as
    9·2 answers
  • We can find out how robots work by looking in detail at the smaller parts. What do we call this?
    6·1 answer
  • What is the difference between a field and an infoobject? What is the advantage of using infoobjects instead of fields in an ads
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!