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
Andy uses a dial-up modem to connect to the Internet. He usually browses news sites, but he notices that online video takes a lo
erastova [34]

Answer:

It is because internet speeds provided by dial-up modem connection are very low.

Explanation:

Andy uses a dial-up modem internet connections. Such connections are very slow. Multimedia files such as videos have large file size. If the speed of the connection is fast, the file will be downloaded quickly to Andy's computer and he can watch them quickly. But through his slow dial-up connection, the files take a long time to download to his computer. This is why it takes such a long time for Andy to view them.e

7 0
4 years ago
5) How have the wireless web and peer-to-peer networking helped small businesses compete with large corporations?
goblinko [34]

It can help them advertise their business

7 0
3 years ago
Read 2 more answers
import java.util.Scanner; public class StudentScores { public static void main (String [] args) { Scanner scnr = new Scanner(Sys
Delvig [45]

Answer:

The code at 'Your solution goes here' is in the bold font given

Explanation:

import java.util.Scanner;

public class StudentScores {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       final int SCORES_SIZE = 4;

       int[] oldScores = new int[SCORES_SIZE];

       int[] newScores = new int[SCORES_SIZE];

       int i;

       for (i = 0; i < oldScores.length; ++i) {

           oldScores[i] = scnr.nextInt();

       }

       for (i = 0; i < oldScores.length - 1; ++i) {

           newScores[i] = oldScores[i+1];

       }

       newScores[oldScores.length-1] = oldScores[0];

       for (i = 0; i < newScores.length; ++i) {

           System.out.print(newScores[i] + " ");

       }

       System.out.println();

   }

}

4 0
3 years ago
DRIVER ED
julsineya [31]

This is true. Motorcycles are much smaller than cars and therefore more easily can slip into a blind spot. Motorcyclists also have less protection than other drivers and would likely suffer more injury in a collision.

4 0
4 years ago
Read 2 more answers
<img src="https://tex.z-dn.net/?f=%5Cmathcal%7B%5Cfcolorbox%7Bblue%7D%7Byellow%7D%7B%5Cred%7BQUESTIONS%3A%7D%7D%7D" id="TexFormu
Paraphin [41]

Answer:

1. A computer network is a set of computers sharing resources located on or provided by network nodes. The computers use common communication protocols over digital interconnections to communicate with each other.

2. A computer network comprises two or more computers that are connected—either by cables (wired) or WiFi (wireless)—with the purpose of transmitting, exchanging, or sharing data and resources

3. LANs are only designed to connect devices. ... In comparison, WANs can connect all of these same devices as well as LANs. In other words, a WAN can connect multiple LANs together so that all of their respective devices can communicate with each other. WANs are also more difficult to set up and maintain than LANs

Explanation:

hope this helps u

4 0
3 years ago
Read 2 more answers
Other questions:
  • 3) Write a program named Full_XmasTree using a nested for loop that will generate the exact output. This program MUST use (ONLY)
    6·1 answer
  • ___________ is a mass-produced, copyrighted software that meets the needs of a wide variety of users, not just a single user or
    15·1 answer
  • How you think the new values of your generation will affect economic decisions?
    11·1 answer
  • Give a logical expression with variables p,q, and r that is true if p and q are false and r is true and is otherwise false.
    5·1 answer
  • Which tab is used to edit objects on the slide master and layouts
    10·1 answer
  • What is an IP address and where I can find the IP address for my computer?
    14·1 answer
  • Which view is easiest and most recommended for changing the order of the slides? A. Slideshow View B. Slide Sorter View C. Readi
    5·2 answers
  • I want to make a game with a friend. I use visual studio code. How do I work on the game with him? Like can he edit the same tim
    10·1 answer
  • Identify the correct answer in each item. Write your answer on the blank provided before
    13·1 answer
  • Ali has created a small program in Python, but he wants to store his data in a multi-dimensional array. He would like to use adv
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!