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
jonny [76]
3 years ago
12

Write a program in c++ that asks the user for a sequence of n​integers, where the user provides the number of elements n​ then e

ach of the elements. After storing the n​ values in the array, ask the user for a value to search within those elements and return the index of the first instance (starting with 0 as the first element). Each integer should be stored in an array in the order they were read from the user. Follow the prompts and output format listed below. The user is expected to enter no more than 256 elements, the array should be able to hold no less and no more​ than 256.
Computers and Technology
1 answer:
timurjin [86]3 years ago
8 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function that return the first occurrence of item

int fun(int a[],int item,int n)

{

   for(int y=0;y<n;y++)

{// find first occurance

   if(a[y]==item)

   // return index

   return y;

}

}

// main function

int main()

{

// variables

int n,item;

// array that holds 256 number only

int a[256];

cout<<"enter the value of n:";

//read the value of n

cin>>n;

// if n is greater than 256, it will again ask for input

while(n>256)

{

   cout<<"value of n should be less than 256:"<<endl;

   cout<<"enter value of n again:";

   cin>>n;

}

// read n numbers

cout<<"enter "<<n<<" numbers:";

for(int x=0;x<n;x++)

{

   cin>>a[x];

}

// read item to be searched

cout<<"enter the number to be searched:";

cin>>item;

// calling the function and print the index

cout<<"item found at index "<<fun(a,item,n)<<endl;

}

Explanation:

Declare a variable "n" and create an array of size 256.Then read the value of "n". If n is greater than 256 then it will again ask user to enter a number less than 256.Then it will read "n" numbers from user and store them into array.Then it will read item to be searched and call the function with parameter array, item and n. function will find the first occurrence of the item and return its index.

Output:

enter the value of n:280

value of n should be less than 256:

enter value of n again:7

enter 7 numbers:12 4 7 9 7 6 21

enter the number to be searched:7

item found at index 2

You might be interested in
Software engineering design teams use ________, which are grounded in mathematical concepts of sets and relations, for their sof
zloy xaker [14]

Answer:

Relational Databases

Explanation:

These are digital databases that are made to recognize relations between previously stored items of info.

4 0
3 years ago
Assume a future where security counter measures against DoS attacks are much more widely implemented than at present. In this fu
Amiraneli [1.4K]

Answer:

yes administrators have to be concerned

Explanation:

It is necessary for countermeasures to be taken against DoS attacks

The types of attacks that can still occur are:

If the network connection get to be overloaded,  there could be flash crown of this computer system and fraudulent activities maybe initiated. By flash crowd  we mean that the there is a great deal of traffic on the system and this could cause the network connection to be destroyed.

To reduce the impact of this kind of attacks,

1. there should be enough or excess network bandwidth  and distributed servers should be replicated if there is a possibility that network could get to be overloaded.

2. restriction is more commonly done on sporting sites. Restriction brings about an increase in implementation cost.

3. The impact of this type of attack can be reduced by stopping unwanted traffic throught the implementation of filters

4. Use strong antivirus on computer sytems that are used to connect to the internet

7 0
3 years ago
Universal containers wants to rollout new product bundles with several pricing options. Pricing options include product-price bu
ololo11 [35]

Answer:

a) Custom AppExchange-app for product-pricing

Explanation:

We can find a solution in AppExchange for this product-pricing, surfing in the option, we could get solutions like BoonPlus, and easy pricing Opportunity, this App has a free trial.

With this option is easy to choose a book price, add new products, select pricing rule, we can get an order's product, and calculate pricing, just we must download the app and install it.

6 0
3 years ago
What is HDLC flow control?​
Likurg_2 [28]
HDLC is a synchronous Data Link layer bit-oriented protocol developed by the International Organization for Standardization (ISO).
6 0
2 years ago
25% of 60 min<br> 20% of 60 min<br> 33%% of 60 min
Alexxx [7]
15
12
19.8 cool cool cool
7 0
2 years ago
Other questions:
  • What tips or techniques should you keep in mind when shooting photographs on a rainy day?
    6·1 answer
  • What is the Code of Conduct/Ethics for the company/of Department of Defense?
    7·1 answer
  • Which of these are examples of a Single Sign-On (SSO) service?
    5·1 answer
  • Which of the following is true regarding packaged software and custom software? Group of answer choices Packaged software are ap
    13·1 answer
  • What is the different between ethical and legal issues?​
    6·1 answer
  • If a computer is not working properly,the best thing to do is ________?
    5·2 answers
  • Which of the following speeches is an example of a demonstration speech? a. “Who was Abraham Lincoln” b. “The Human Brain and it
    5·1 answer
  • The signature area in a cover letter includes the sender's first and last name, followed by his/her job title (if applicable). *
    13·1 answer
  • Which bits of the address would be used in the tag, index and offset in a two-way set associative cache with 1-word blocks and a
    7·1 answer
  • Name various input and output devices used with computers.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!