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
A computer has the following parameters Operation Frequency Cycles Arithmetic/Logical instructions 65% 1 Register load operation
Julli [10]

Answer:

that right

Explanation:

i agree

4 0
3 years ago
Select three advantages of cloud computing.
777dan777 [17]

Answer:

easily managed, large amount of storage capacity, great flexibility

Explanation:

5 0
3 years ago
We are sending a 30 Mbit MP3 file from a source host to a destination host. All links in the path between source and destination
Daniel [21]

Answer:

Option  A is the correct answer.

Explanation:

8 0
3 years ago
Acquiring new knowledge and skills at every stage of life:
Artist 52 [7]

d. lifelong learning

6 0
1 year ago
Read 2 more answers
Rikki has had several problems at work recently. Her printer isn't printing correctly, copies from the copy machine come out wit
Ghella [55]
Create a maintenance schedule 
3 0
3 years ago
Read 2 more answers
Other questions:
  • In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sid
    10·1 answer
  • What can be done to improve the security of business uses of the Internet? Give several examples of ecurity measures and technol
    9·1 answer
  • A computer is defined by 4 specific criteri. Select all 4.*
    7·1 answer
  • What is a Photojournalist
    5·1 answer
  • Which guideline should you use when downloading software from the Internet?
    15·1 answer
  • Thomas has signed a deal with a production house that allows them to use his images on their website. What is required when imag
    5·2 answers
  • Which method is used for resolving data dependency conflict by the compiler itself?
    6·1 answer
  • How to Calculate the area of a rectangle in python
    13·2 answers
  • Which of the following is not the disadvantage of closed
    7·2 answers
  • A keyboard would be considered what 2 things
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!