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
HELP ME PLEASE !!!!!!!!!!
Snezhnost [94]

Answer:

the last one

Explanation:

8 0
3 years ago
It takes you 0.8 of a minute to read each page of your health book. It takes you 5.5 minutes to take the test at the end. How lo
NeTakaya
The answer would be 13.3125 because 6.25 / 0.8 is 7.8125 than add 5.5 which will equal 13.3125. I'm sure about this.
7 0
3 years ago
Read 2 more answers
In some video games, the player cannot obtain the reward without doing what with something that they already have?
Crank

Answer:

risking

Explanation:

8 0
3 years ago
Explain basic anatomy of computers.
jeyben [28]

Explanation:

A computer system can be divided into two components which are responsible for providing the mechanisms to input and output data, to manipulate and process data, and to electronically control the various input, output, and their storage. ... They are known as hardware and software.

4 0
2 years ago
Read 2 more answers
What is HTML ? <br>Give a small description about html
Genrish500 [490]
Hypertext Markup Language, a standardized system for tagging text files to achieve font, colour, graphic, and hyperlink effects on World Wide Web pages.
this information was taken from google
7 0
2 years ago
Read 2 more answers
Other questions:
  • Describe the general process of creating a DataFlow Diagram (DFD)
    7·1 answer
  • Define the missing method. licenseNum is created as: (100000 * customID) licenseYear, where customID is a method parameter. Samp
    14·2 answers
  • What do astronomers call a system that is composed of more than two stars?
    9·2 answers
  • Explain the developments RAM since it was created in 1968 til today.
    7·1 answer
  • Why does my inbox keep getting notifications and then disappearing?
    15·2 answers
  • While reviewing system logs, a security analyst notices that a large number of end users are changing their passwords four times
    13·1 answer
  • What happens when text is added to grouped objects that is larger than an object ?
    9·2 answers
  • Como a contribuido el desarrollo tecnologico a mejorar la calidad debida de los seres humanos
    11·1 answer
  • Paul wants to store addresses and phone numbers for clients. Paul wants to use this information to send form letters. Paul shoul
    5·1 answer
  • Help plz (will give brainliest)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!