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
zmey [24]
3 years ago
14

Write a program called array1.cpp file that use either regular for loop or range based for loop to display the contents of the a

rray test []. You can also write a function to display the contents of array. Submit your code array1.cpp to Blackboard.
Computers and Technology
1 answer:
ch4aika [34]3 years ago
7 0

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

void display(int array_test [], int n){

   for(int i = 0; i<n;i++){

       cout<<array_test[i]<<" ";   }

}

int main(){

   int n;

   cin>>n;

   int array_test[n];

   for(int i = 0; i<n;i++){

       cin>>array_test[i];

   }

   display(array_test,n);

   return 0;

}

Explanation:

This defines the display function

void display(int array_test [], int n){

This iterates through the array

   for(int i = 0; i<n;i++){

This prints each element of the array

       cout<<array_test[i]<<" ";   }

}

The main begins here

int main(){

This declares n as integer; n represents the length of the array

   int n;

This gets input for n

   cin>>n;

This declares the array

   int array_test[n];

The following iteration gets input for the array

   for(int i = 0; i<n;i++){

       cin>>array_test[i];

   }

This calls the display function to display the elements of the array

   display(array_test,n);

   return 0;

}

You might be interested in
The fastest way to get help is to type a word or two in the search box.
Elanso [62]
The fastest way to get help is to type a word or two in the search box. TRUE.
5 0
4 years ago
True or false? Opinionated websites can still be credible. A. True B. False
kumpel [21]
False. the information should not be biased in order to be creditable
5 0
4 years ago
Read 2 more answers
Can we change the format of a field (e.g. Number to Dollars).
mixer [17]

I think the answer is

3 - Usually, but we may need to convert the data types (date to text)

Because we can change the format, but depends of the original format type and in what type you need to format.

I think this can help.

3 0
4 years ago
A library function that can find one string inside another is:
Lostsunrise [7]
In c# and java it's indexOf
7 0
3 years ago
Which feature of a typical professional networking site helps users add professional details to their profile?
andrew11 [14]
A biography page that tells about the person and has their expertise listed as well as contact information and sometimes previews
4 0
3 years ago
Read 2 more answers
Other questions:
  • What are the three most important jobs of an operating system?
    8·1 answer
  • The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the firs
    9·1 answer
  • A workplace is where people _____. a. do work b. find new jobs c. go when they are unemployed d. read advertisements for job ope
    15·1 answer
  • What is a mortgage?
    8·2 answers
  • Signals that can travel in only one direction on a medium are referred to as what type of signal?
    12·1 answer
  • Suppose users share a 1-Gbps link. Also, suppose each user requires 200 Mbps when transmitting, but each user only transmits 30
    5·1 answer
  • How can a cell phone tower help people​
    11·2 answers
  • Cui documents must be reviewed to which procedures before destruction?
    13·1 answer
  • Computers and their input and output devices require power to work and may have many power cords. What is the safest way to orga
    7·1 answer
  • Assuming a single-processor system, that load and store are atomic, that x is initialized to 0, and that x must be loaded into a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!