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
expeople1 [14]
2 years ago
7

Write a program that accepts an integer value called multiplier as user input. Create an array of integers with ARRAY_SIZE eleme

nts. This constant has been declared for you in main, and you should leave it in main. Set each array element to the value i*multiplier, where i is the element's index. Next create two functions, called PrintForward() and PrintBackward(), that each accept two parameters: (a) the array to print, (b) the size of the array. The PrintForward() function should print each integer in the array, beginning with index 0. The PrintBackward() function should print the array in reverse order, beginning with the last element in the array and concluding with the element at index 0. (Hint: for help passing an array as a function parameter, see zybooks section 6.23) As output, print the array once forward and once backward.
Computers and Technology
1 answer:
Tasya [4]2 years ago
6 0

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

void PrintForward(int myarray[], int size){

   for(int i = 0; i<size;i++){        cout<<myarray[i]<<" ";    }

}

void PrintBackward(int myarray[], int size){

   for(int i = size-1; i>=0;i--){        cout<<myarray[i]<<" ";    }

}

int main(){

   const int ARRAY_SIZE = 12;

   int multiplier;

   cout<<"Multiplier: ";

   cin>>multiplier;

   int myarray [ARRAY_SIZE];

   for(int i = 0; i<ARRAY_SIZE;i++){        myarray[i] = i * multiplier;    }

   PrintForward(myarray,ARRAY_SIZE);

   PrintBackward(myarray,ARRAY_SIZE);

   return 0;}

Explanation:

The PrintForward function begins here

void PrintForward(int myarray[], int size){

This iterates through the array in ascending order and print each array element

<em>    for(int i = 0; i<size;i++){        cout<<myarray[i]<<" ";    }</em>

}

The PrintBackward function begins here

void PrintBackward(int myarray[], int size){

This iterates through the array in descending order and print each array element

<em>    for(int i = size-1; i>=0;i--){        cout<<myarray[i]<<" ";    }</em>

}

The main begins here

int main(){

This declares and initializes the array size

   const int ARRAY_SIZE = 12;

This declares the multiplier as an integer

   int multiplier;

This gets input for the multiplier

   cout<<"Multiplier: ";    cin>>multiplier;

This declares the array

   int myarray [ARRAY_SIZE];

This iterates through the array and populate the array by i * multiplier

<em>    for(int i = 0; i<ARRAY_SIZE;i++){        myarray[i] = i * multiplier;    }</em>

This calls the PrintForward method

   PrintForward(myarray,ARRAY_SIZE);

This calls the PrintBackward method

   PrintBackward(myarray,ARRAY_SIZE);

   return 0;}

You might be interested in
Implemente a função ao lado, que recebe um preço e um booleano indicando se já está com desconto ou não. Se o preço for maior qu
Andrew [12]

Answer:

function pecoDesconto(preco, estaComDesconto) {

 

 let p = preco;

 let desconto = estaComDesconto;

 if(p > 100 && desconto == false){

   return "Quero pechinchar";

 }else{

   return "Negócio fechado";

 }

}

Explanation:

function pecoDesconto(preco, estaComDesconto) {

 

 // Implemente a função ao lado, que recebe um preço//

 let p = preco;

// variavel que indica desconco//

 let desconto = estaComDesconto;

//Se o preço for maior que 100 e não estiver com desconto, a função deve retornar Quero pechinchar.//

 if(p > 100 && desconto == false){

   return "Quero pechinchar";

   //Caso contrário, deve retornar Negócio fechado

 }else{

   return "Negócio fechado"

 }

}

só te faltou ler com atenção, e um pouco de logica!

7 0
2 years ago
Clive wants to write a query that will display the names of the students who scored less than 10 in their final exams. Which num
Mice21 [21]
I'd go for <span>FLOOR(x)
</span>

The numerical function FLOOR(x) can be used to return the largest integer value that is less than or equal to the numerical expression provided. The numerical function CEILING (x) is the opposite of FLOOR(x) since it gives the smallest integer value that is greater or equal to the numerical expression.






6 0
2 years ago
Read 2 more answers
A _____ cloud allows an organization to take advantage of the scalability and cost-effectiveness that a public cloud computing e
balu736 [363]

Answer:

Hybrid

Explanation:

Hybrid cloud is a solution that combines a private cloud with one or more public cloud services, with proprietary software enabling communication between each distinct service.

5 0
3 years ago
Which of the following savings vehicles usually requires a high minimum balance
GuDViN [60]
A Savings Vehicle is an effective way to hold your savings. It could be a savings account. But some requires a high minimum balance such as Certificate of Deposit (CD). It is generally issued by commercial banks.  It is a time deposit too and restricts you from withdrawing funds.
7 0
3 years ago
Jakob is stuck in the airport on a long layover while traveling for work. He sees two Wi-Fi’s he can log onto: one says Airport
Andrei [34K]
You should pick Free Airport Wifi bc its free
3 0
3 years ago
Read 2 more answers
Other questions:
  • Krystal recorded her times for all her cross-country meets this season. To sort her data showing the lowest times first, what wi
    14·2 answers
  • Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;
    7·1 answer
  • When selecting text in word, holding down the ctrl key while clicking the mouse button will select the?
    15·1 answer
  • While surfing online, Patricia checks her email and reads the latest messages. She then browsers a website and logs in a comment
    8·1 answer
  • PLEASE ANSWER ASAP
    7·1 answer
  • __________ is a very simple form of lossless data compression in which runs of data (that is, sequences in which the same data v
    6·1 answer
  • You will implement three different types of FFs with two different reset types. You have to show your results on your FPGA. You
    9·1 answer
  • How many pieces can be connected on to a to an SPS​
    11·1 answer
  • jeff has just upgraded from windows 7 to windows 10 and he is confused. He has started several universal apps but he can't figur
    11·1 answer
  • Please answer the following question in Verilog.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!