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
20 points/ When creating a storyboard, in which section do you mention how you move from one shot to the next?
kondor19780726 [428]

Answer:

Transition  section helps us to move from one shot to the next.

Explanation:

Synopsis: This tells actually what is the story is all about. We can call that as a “short description about the story”.

Sketch: It is the drawing window, where we pictorially represent the story.

Transition: This actually tells us about the next move.

Shot description: We can consider a “shot” as one of the scene in the story. So, it shot contain image and its description.

Shot Sequence: This is for “Pre-visualizing” video.

Among all the choice, Transition option takes the write definition.

5 0
3 years ago
If you notice files being transferred to or from your computer a. Simply close the window c. Tell the lab instructor b. Open a n
a_sh-v [17]

Answer:

The best answer is letter D.  

Explanation:

Downloading of files without your permission is a form of security threat and attack. You as unwilling victim will have your files and private information stolen.

One of the basics of internet security is to terminate any connection that you have in a network to stop the possible attack or threat. Worst case scenario is we can shut down our computers or devices or gadgets. But if we can just terminate the connection without performing a force shut down on the device, it is much better. This will give us more time to save what we are working on and to prevent losing important works or data. Terminating the connection from the network comes in various activities such as:  

*Disconnect from the internet - this is one of the most effective method. As most of the attacks are coming from external threats such a hacking.  

*Closing the browser - this could be helpful as well. Hackers are using browser to monitor their victims. And malwares and adwares are most active while we use browsers as they are embedded and using it to propagate to peform their activities.  

*Disconnect from the local network - if you have closed the internet connection and any active software that you are working on presently and the downloading of files still persists, probably the attack comes from your local network. You must close any connection that you have within the local network.

*Deleting the recent files you have downloaded - You must delete any recent files that you just downloaded from your email or from the internet. There might be malware embedded in the file. Malwares are used by hackers to get in to their victims computer without them knowing it.

Then after terminating all the connections, you must call on your Instructor's attention. He / She is the authority in charge and must be aware of the situation.

5 0
2 years ago
Read 2 more answers
Why Embedded operating systems are also known as real-time operating systems (RTOS)?
kati45 [8]

Answer:

A real-time operating system is an operating system designed to support real-time applications that, usually without buffer delays, process data as it comes in. A real-time system is a time-bound system that has fixed, well defined time constraints.

6 0
3 years ago
A security system uses sensors at every door and window which will set off an alarm if any one of them is opened. There is also
jeka57 [31]
Well think of it like this lets say this wasn't and security system and it was a video game console and remote.
 Now the console or keypad or the main components the power on or shut off the devices and the remote or sensors are the secondary parts but they are needed to help the console or keypad figure out what they are doing.
5 0
3 years ago
Provide a status report to your classmates and instructor. Describe any modifications that you have made to the design or docume
Pavel [41]

Answer:

that's muddled up I can't make out the question

3 0
3 years ago
Other questions:
  • What happens if i receive a text while my phone is off?
    15·1 answer
  • In your memo, give three new employees directions for starting the computer and opening a word-processing document.
    9·1 answer
  • Name similarities between innovation and invention
    6·1 answer
  • On his computer desktop, Rodney can see several different files, each immediately accessible. Because he is actively working on
    13·1 answer
  • My friend Leo wants to have an emergency plan for his final exams on University of Southern Algorithmville. He has N subjects to
    6·1 answer
  • Janet received an email from a bank asking for the password for her Internet banking account. She emailed back her password. A f
    12·2 answers
  • How to create a network of relevant prospects?
    5·1 answer
  • The Curiosity Rover has recently landed on Mars and likes to send Twitter updates on its progress. If a tweet is posted 10 minut
    6·1 answer
  • You are a developer for a news, entertainment, lifestyle, and fashion website. User traffic has steadily increased month-over-mo
    11·1 answer
  • Years ago when working a helpdesk, the most common question asked, almost daily, was about resetting passwords. What type of kno
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!