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
What would happen if a pc that contains a power supply that does not automatically adjust for input voltage is set to 230 volts
frutty [35]
It would be underpowered which results in poor performance or won't turn on
3 0
3 years ago
A developer is creating an enhancement to an application that will allow people to be related to their employer. Which data mode
vredina [299]

Answer:

B. Create a lookup relationship to indicate that a person has an employer

Explanation:

Programmers are professional who build computer softwares.

Creating a lookup relationship to indicate that a person has an employer is the data model used to track the data of a developer creating an enhancement to an application that will allow people to be related to their employer. This data model allows for 25people per object.

5 0
3 years ago
What type of firestopping technology expands as much as 25 times in volume?
love history [14]
The answer is Intumescent. I am pretty sure this is right.
7 0
3 years ago
WILL GIVE BRAINLIEST!!!!!!!
pishuonlain [190]

Answer:

False

Explanation:

Central Louisiana Regional Port is the small river port (not in a top 100 ports), while New Orleans Port is  $100 million a year reveniew huge port, 7th busiest in US.

3 0
3 years ago
Match the technology with the appropriate task.
Fiesta28 [93]

Answer:

the number order is

1

5

2

4

3

Explanation:

I am sure it is correct. Thanks :)

3 0
3 years ago
Other questions:
  • Drag the correct type of update to its definition.
    5·1 answer
  • I need help please?!!!
    15·1 answer
  • A(n) _______ created in Microsoft Word or another word-processing program works well as a shell for a PowerPoint presentation.a.
    9·1 answer
  • How to use javascript libraries in javascript code?
    9·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • In determining where to store specific data in a(n) centralized DBMS, factors such as communications cost, response time, storag
    12·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    5·1 answer
  • What was used to enhance silent films of the early 1900s
    15·1 answer
  • Similarities between inline css and internal css​
    6·1 answer
  • What channel does the news come on? <br><br> i dont have cable i have roku :\
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!