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
topjm [15]
3 years ago
14

Write a function named firstLast2 that takes as input an array of integers and an integer that specifies how many entries are in

the array. The function should return true if the array starts or ends with the digit 2. Otherwise it should return false. Test your function with arrays of different length and with the digit 2 at the beginning of the array, end of the array, middle of the array, and missing from the array.
Computers and Technology
1 answer:
frosja888 [35]3 years ago
4 0

Answer:

<em>Written in C++</em>

#include<iostream>

using namespace std;

int firstLast2(int arr[], int n);

int main()

{

int n;

cout<<"Number of Elements: ";

cin>>n;  

int myarray[n];

for(int i = 0; i<n;i++) {

cin>>myarray[i];

}

firstLast2(myarray, n);

return 0;

}

int firstLast2(int arr[], int n){

if(arr[0] == 2 || arr[n - 1] == 2) {

 cout<<"True";

}

else {

cout<<"False";

}

}

Explanation:

<em>I've added the full source code as an attachment where I used comments to explain difficult lines</em>

Download cpp
You might be interested in
You’ve been stuck in bumper-to-bumper traffic for nearly an hour on a hot summer day. The temperature warning light has just com
nekit [7.7K]

Answer:

In a bumper-to-bumper traffic, when the engine starts overheating the situation can be handled by tapping the accelator which will revive the engine.

Explanation:

Overheating of engine can be due to many reasons. But one should know what to do when an engine overheats in a traffic. Bumper-to-bumper traffic is when the cars are so close in traffic that they touch each other. This usually happens when there's a traffic for a long time or on very busy lane. During summer times, it is important to keep checking the engine temperature to avoid any problem.

When one is stuck in bumper-to-bumper traffic with overheating engine, then there are some meausres that one can take. They are:

  • To put the car on park or neutral mode of driving and tap the accelator which will revive the engine.
  • The heat can be disperse by rolling down the window and turn the heater up. It will disperse the heat.

6 0
3 years ago
This feature in Word Online allows you to view your document to see what it will look like when printed.
kherson [118]

Answer:

Print preview allows you to view your document before printing

7 0
3 years ago
Read 2 more answers
An acceptable website design is one that meets
Harman [31]

Answer:

i'd say b

Explanation:

5 0
2 years ago
Read 2 more answers
Variablesallow us to manipulate data through the ___________.
gladu [14]

Answer:

Reference

Explanation:

Variables provide reference to the stored data value.

For example:

int i = 0;

Here i is a variable of type int with an initial value of 0. i is a reference to this stored value 0. Now if I want to update the data, I can do so using this reference.

i = 1;

Now the reference is used to manipulate the stored data and change it to 1. In a similar manner all updates to the value can be done using the variable reference.

8 0
3 years ago
Allie needs to add a long row of numbers. She should enter a
ikadub [295]
I believer the answere is a formula hope this helped
8 0
3 years ago
Read 2 more answers
Other questions:
  • Laura is photographing her son’s baseball game. What ISO setting should she use?
    11·1 answer
  • Write a MATLAB script using the quiver and contour commands to visualize the field and its divergence. Assume the region of inte
    12·1 answer
  • write the structure of an email message ques.2 what do you mean by search engine? write its component .ques. 3 what are the adva
    9·1 answer
  • Tortise and hare race java g Modify the main class so it runs the race 100 times and reports how many times each runner wins. (T
    7·1 answer
  • Code embedded into an HTML page and downloaded by a user; resides on the client and helps process Web form input. Common clients
    9·1 answer
  • Which of these statements regarding​ time-cost tradeoffs in CPM networks is​ true?
    6·1 answer
  • Which program will have the output shown below?
    7·1 answer
  • The term Linux Intrusion Detection System ( LIDS) refers to a command that allows an administrator to run processes as root with
    5·1 answer
  • Examples of email prividers​
    6·2 answers
  • Which storage device is not recommended as a permanent storage solution?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!