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
When Creating a game ( Which I Am, FPS ofc ) what are the basic rules would you want to add
Gnesinka [82]

Answer:

2 ig

Explanation:

5 0
4 years ago
WILL MARK BRAIN LIST!
Tcecarenko [31]

Answer:

try D not sure

Explanation:

sorry if wrong happy if right!!!!!!

6 0
3 years ago
Read 2 more answers
The image shows a sample group contract.
Shtirlitz [24]

Answer: c

Explanation:I done this before;DDD

8 0
3 years ago
Read 2 more answers
Which line of code will create an instance of the pet class?
Sunny_sXe [5.5K]

Answer:

myPetA = pet(self, 'dog', 'Spot')

Explanation:

I mite be wrong

8 0
3 years ago
Read 2 more answers
Why would you use a custom filter?
Angelina_Jolie [31]

Answer:By specifying conditions, you can create custom filters that narrow down the data in the exact way that you want. You do this by building a filter. If you've ever queried data in a database, this will look familiar to you. Point to either Number Filters or Text Filters in the list.

Explanation:

5 0
3 years ago
Other questions:
  • 1) The program reads an integer, that must be changed to read a floating point. 2) You will need to move that number into a floa
    6·1 answer
  • . How is a form used?
    10·1 answer
  • What is the name of the contextual or specific tab that appears in page layout view when adding a header
    15·1 answer
  • The set of communications rules for exchanging information electronically on the internet is called the ________.
    10·1 answer
  • While software vendors generally provide evaluation or demonstration copies of their products, hardware vendors never provide ev
    15·1 answer
  • Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, fir
    9·1 answer
  • A newspaper wants to estimate the proportion of Americans who will vote for Candidate A. A random sample of 1000 voters is selec
    14·1 answer
  • With Voice over Internet Protocol (VoIP), _____. a. voicemails cannot be received on the computer b. call quality is significant
    6·1 answer
  • Describe how a computer checks whether the image just taken by the camera matches the scanned photograph.
    12·1 answer
  • A keyboard would be considered what 2 things
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!