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
If you need to multiply 50 and 8 and divide by 2, what would you type on the numerlc keypad?
nata0808 [166]

Answer:

50*8/2

The asterisk is the multiplication sign and the parenthesis is the division.

I've never used an apostrophe for a multiplication sign before, but I'm guessing multiplication is what it stands for.

Explanation:

4 0
2 years ago
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This
Shtirlitz [24]

Answer:

def newton(n):

       #Define the variables.

       t = 0.000001

       esti = 1.0

       #Calculate the square root

       #using newton method.

       while True:

               esti = (esti + n / esti) / 2

               dif = abs(n - esti ** 2)

               if dif <= t:

                       break

   

       #Return the result.

       return esti

#Define the main function.

def main():

   

       #Continue until user press enters.

       while True:

               try:

         

                       #Prompt the user for input.

                       n = int(input("Enter a number (Press Enter to stop):"))

                       #display the results.

                       print("newton = %0.15f" % newton(n))

     

               except:

                       return

#Call the main function.

main()

7 0
3 years ago
The number of pixels displayed on the screen is known as ​
puteri [66]

Answer: Resolution

Explanation: The total number of pixels that can be displayed on the screen at a time is called the resolution of the screen. This resolution is normally described in the pair of numbers, such as 2560 x 1440. This means, the computer screen is 2560 pixels wide and 1440 pixels tall.

4 0
3 years ago
A user reports that a file they shared out on their computer for another network user is not accessible to the third party. The
muminat

Answer:

i think it's going to be c

Explanation:

3 0
3 years ago
Traffic flow analysis is classified as which?
Anna35 [415]

Answer:

c. An active attack

d. A passive attack​

Explanation:

Traffic flow analysis is a cyber attack method of acquiring information by intercepting and examining messages so as to decode them by analysing patterns in the way the messages are communicated.

Traffic flow analysis can either be active or passive depending on if the attacker alters communication in the case of active analysis or simply extracts information in case of passive analysis.  

8 0
2 years ago
Other questions:
  • You're browsing the Internet and realize your browser is not responding. Which of the following will allow you to immediately ex
    5·2 answers
  • The ________ multiple-selection PHP statement is used to handle decision making and can be used to replace multiple if and if...
    12·1 answer
  • Your wearable device synchronized with your smartphone this morning when you turned it on, but the two devices no longer are syn
    14·1 answer
  • End user needs assessment is a formal procedure to analyze a user's computer needs; it involves a specific set of steps that are
    8·1 answer
  • What is the advantage of maintaining a list of keywords while creating a design blueprint?
    13·2 answers
  • What is the behavior of an element with static positioning in regard to the page layout?
    12·1 answer
  • How does Shakespeare immediately introduce Tybalt as a menacing character?
    9·1 answer
  • What are two different ways by which a laptop could utilize the cellular network connection of a mobile device
    15·1 answer
  • When evaluating an AND operator, what is necessary for execution?
    7·1 answer
  • You find information that you know to be classified on the internet. What should you do.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!