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
Sedaia [141]
3 years ago
10

Create a method to search an un-ordered array of integers for a value, if the value is found return the index of its position in

the array, if not found, return -1.
Computers and Technology
1 answer:
Hatshy [7]3 years ago
6 0

Answer:

Following are the program in C++ language  

#include <iostream> // header file

using namespace std; // namespace

int search(int s[],int s1,int n) // function search  

{

   for (int k= 0; k<n; k++) // iterating over the loop

 {

   if (s[k] == s1)   // searching the element  

   {

   return(k); // return the index

     break;

   }

 

}

return(-1); // return(-1)

}

int main() // main function

{

int arr[100],n1,i,s; // variable declaration  

cout<<"Enter number you want in the array:";

cin>>n1;

cout<<"Enter the elements in the array\n ";

for (i = 0; i<n1; i++)

{

   cin>>arr[i]; // taking input into the array  

}

 cout<<"Enter a number you want to search: ";

cin>>s; // read the serach element by the user  

int res= search(arr,s,n1); // calling function search

cout<<res; // display result

 return 0;

}

Output:

Enter number you want in the array:3

Enter the elements in the array

1

2

34

Enter a number you want to search: 2

2

Explanation:

Following are the description of the program  

  • Read the number you want in array in the "n1" variable of int type.
  • Read the array by the user in the "arr ".
  • Read the searching element in the  "s" variable.
  • calling the function search by passing array arr, searching element "s" and "n1".
  • In the search function, it returns the index of its position in the array, if not found then it return -1.
  • Finally print the index.  

You might be interested in
​___________ contain microprocessors and tiny antennas that allow them to​ receive, store, and transmit​ data, such as the locat
Gwar [14]

Answer:

The correct option is C: Radio frequency identification tags

Explanation:

Radio frequency identification tags also known as RFID tags involves the use of radio waves to​ receive, store, and transmit​ data which are usually stored on a tag that is attached to an object. A tag contains microprocessors and tiny antennas and whether it is in line of sight or not, it can be tracked and information transmitted from it.

4 0
3 years ago
You can use the ____ command to delete an entire table and its data.?
jek_recluse [69]
You can press control and x at the same time, the delete button, or backspace
6 0
4 years ago
Acid rain is a major biological concern because it damages both living and nonliving things.
Solnce55 [7]
True is the right one    
6 0
4 years ago
In a network, servers receive requests from which of the following?
Margarita [4]

Answer: routers, which direct the data to the correct destination.

Explanation:

In a network, servers receive requests from the routers, which direct the data to the correct destination.

The router simply refers to the networking device which helps in the forwarding of data packets between the computer networks. When a data packet is sent through one of the lines, then the information regarding the network address will be read by the router which will help it in determining the destination.

5 0
3 years ago
Read 2 more answers
The Sarbanes-Oxley Act restricts electronic and paper data containing personally identifiable financial information.A. True
Zarrin [17]

Answer:

B. False

Explanation:

Sarbanes-Oxley Act or SOX also known as the Public Company Accounting Reform and Investor Protection Act and Corporate and Auditing Accountability, Responsibility, and Transparency Act is a United State federal law that creates or modify requirements for U.S public company board, management and public accounting firm. some of its policies are meant for private companies as well.

This act does not restrict any electronic and paper data containing personally identifiable financial information.

6 0
4 years ago
Other questions:
  • Which Windows system utility contains a comprehensive list of the devices connected to your computer and displays warning icons
    8·1 answer
  • Which organization has published more than 300 web standards
    7·1 answer
  • What are the similarities and differences between the sample résumés, in terms of content and formatting?
    10·1 answer
  • What does it mean to use too much jargon in a slide presentation?(computer applications)
    9·2 answers
  • A user attempts to log in to a Windows PC, but the computer returns to the login screen after entering the correct username and
    12·1 answer
  • Please help will give brainliest
    12·1 answer
  • ______________ memory is a small, high-speed, high-cost memory that servers as a buffer for frequently accessed data
    9·2 answers
  • Use the drop-down menus
    9·2 answers
  • When a number gets assigned to a variable that already has a value __________. the new number overwrites the previous value at t
    9·1 answer
  • Aurelia is designing a user interface for a new game app. Which of the following should she taken into consideration for the use
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!