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]
2 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]2 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
What correlation is obtained when the pearson correlation is computed for data that have been converted to ranks?
professor190 [17]

The correlation that is obtained when the pearson correlation is computed for data that have been converted to ranks is option A) The Spearman correlation.

<h3>What is Spearman correlation used for?</h3>

Spearman's correlation is known to be one that tends to look into or measures the strength and way of monotonic relationship between two variables.

It is one that is a nonparametric measure that is often known to be rank correlation and it tends to examine  how well the association between two variables can be said to using a monotonic function.

Hence, The correlation that is obtained when the pearson correlation is computed for data that have been converted to ranks is option A) The Spearman correlation.

Learn more about correlation from

brainly.com/question/12479370

#SPJ4

See full question below

) What correlation is obtained when the Pearson correlation is computed for data that have been converted to ranks?

A) The Spearman correlation

B) The point-biserial correlation

C) The phi coefficient

D) It is still called a Pearson correlation

8 0
1 year ago
In order for the wavelength of a wave to increase, the frequency must...
kari74 [83]
Decrease. Think like this, if you were standing in the ocean getting hit by waves, frequency would be how many waves hit you in a certain amount of time. If there were lots of little waves hitting you the number of waves (the frequency) would be high, whereas big waves are slower and take more time to reach you so you would get hit by less of them in the same time frame. The less frequent, the longer the wave. 
7 0
2 years ago
What are some ways in which reading and writing have changed in our newly networked world
olga_2 [115]
Reading and writing have given us both a way to pass on knowledge and learn things we cant learn first hand.<span />
3 0
3 years ago
I need help ASAP please
Sunny_sXe [5.5K]

Answer:

The best way is 2 and the worst is 1

Explanation:

7 0
3 years ago
Read 2 more answers
Explain three of the the features of the word processing to document. ​
boyakko [2]

Word processing software may be used to create, edit, save, and print documents, among other things. Text within a document may be copied, pasted, moved, and deleted. Text formatting includes font selection, bolding, underlining, and italicizing.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Which is an example of intrinsic motivation?
    13·2 answers
  • Sizing handles are used in Microsoft® Word® to _____.
    13·1 answer
  • What is the difference between 1080p and 2k?
    14·1 answer
  • Write the definition of a function typing_speed, that receives two parameters. The first is the number of words that a person ha
    9·1 answer
  • Which is a benefit of owning a desktop computer instead of a laptop?
    13·2 answers
  • 8. A pattern of being late for work or for appointments is usually
    12·1 answer
  • All resources are limited. Which of the following is NOT a resource?
    11·1 answer
  • Andrea needs to format the legend on her chart. She clicks on the chart to select it. Which of the
    13·1 answer
  • I NEED HELP ASAP!
    6·2 answers
  • How was the addition of an improvement over early web design?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!