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
Sergio [31]
4 years ago
11

Write a squareNreverse function that takes an integer array and its length as arguments. Your function should first square each

element of the array and then it should reverse the contents of the array, leaving the final output in the original array, and return nothing. Demonstrate the function in a main program that asks the user to enter 5 integers, stores them in an integer array, calls the squareNreverse function on this array, and then outputs the content of the array
Computers and Technology
1 answer:
slega [8]4 years ago
3 0

Answer:

Following are the code to this question:

#include <iostream>//defining header file

using namespace std;//use package

void squareNreverse(int arr[], int size)//defining a method squareNreverse

{

int i,t,j;//defining integer variable

for (i = 0; i < size; i++)//defining loop for calculate square of array

{

arr[i] = arr[i] * arr[i];//calculate square and store its value

}

i = 0;//assign value 0 in i variable

j = size - 1;// hold size value

while (i < j)//defining while loop  for calculate reverse value

{

t = arr[i];// store array value in t variable

arr[i] = arr[j];//defining arr[i] to store in arr[j]

arr[j] = t;//assign a[j] in t

i++;//increment i value

j--;//decrease j value

}

cout << "Displaying the Reveersed Array after Squared :" << endl;//print message

for (i = 0; i < size; i++)//defining for loop

{

cout << arr[i] << "\t";//print array value

}

}

int main()//defining main method

{

int size = 5;//defining size variable that hold value 5

int arr[size];//defining arr as an integer array

cout << "Enter elements :"; //print message

for (int i = 0; i < size; i++)//defining for loop for input value

{

cin >> arr[i];//input value

}

squareNreverse(arr, size);//call method squareNreverse

return 0;

}

Output:

Enter elements :2

3

4

5

6

Displaying the Reveersed Array after Squared :

36 25 16 9 4  

Explanation:

In the given code a method, "squareNreverse" is defined that accepts an array and a size variable as a parameter, and inside the method, three integer variable "i,j, and t" is defined, in which i and j are used in the loop for calculating the square value and t is used for reverse the array value, and the print method is used for print reverse array value.

In the main method, an array "arr" and size is defined, which use for loop for input value from the user end, and at the last, we call the method "squareNreverse" bypassing array and size value.    

You might be interested in
How can IT infrastructure be linked to the business strategy of any organization
Anni [7]

Answer:

The overview of the situation is discussed in the following part.

Explanation:

It's indeed real that perhaps IT technology will have a strategic edge and improved market efficiency. IT technology can improve the protection, accessibility, and efficiency of any enterprise.

Numerous massive, small as well as medium-sized companies or beginning are currently preparing their growth plans by sustaining a stable IT infrastructure throughout the place that will ensure and increase their profitability.

<u>Those same years, the accompanying IT infrastructure is being used to connect the market strategy</u>:

  • Broadband and Wireless Connectivity,
  • Security and Risk Management,
  • IT Structure Strategy,
  • Performance Strategy, etc.
7 0
3 years ago
Name 3 examples of operating system software that are not Windows based.
anyanavicka [17]
Ubuntu, Linux, and Mint
4 0
3 years ago
For her homework, Annie has added the picture of a fruit in a document. She wants to enhance it to give a cut-out look. Which fe
Kaylis [27]

Answer:

Explanation:

We must follow several steps:

  1. We must click in the image
  2. Click Image Tools > Format
  3. Click the date under Crop
  4. We must resize the image, or Trim one side, Trim two adjacent sides, Trim the same fragment.
  5. Click the Crop button again if you finished

In addition, we can change the form of the image, we have a lot of options in crop to shape.

8 0
3 years ago
Read 2 more answers
How can knowing internal and external parts of computer help me
mafiozo [28]
Going over parts of a computer and how it functions will help you understand all the vital components that make up a computer.
8 0
3 years ago
Can you please look through this code and see wants wrong with it? its in python
Ivanshal [37]
I’m confused what are you trying to ask? What is the python?
3 0
3 years ago
Other questions:
  • Para saan po yung points dito?
    15·1 answer
  • Which of the following is a narrative essay most like
    8·2 answers
  • Samantha plans an investigation in which she will study a population of animals. Which of these answers best describes the focus
    8·1 answer
  • : How does the founder of Wikipedia keep a tight reign on accuracy? HELP PLEZ AT LEAST A PARGRAPH PLES
    6·1 answer
  • A) A cable that is mainly used in the cable television network
    11·1 answer
  • A program that processes data submitted by the user. Allows a Web server to pass control to a software application, based on use
    11·1 answer
  • Given two strings s and t of equal length, the Hamming distance between s and t, denoted dH(s,t), is the number of corresponding
    6·1 answer
  • A ________ is a question you ask about data stored in a database
    9·1 answer
  • Help pweeze this is due today :(<br><br> I will give u brainliest just pweeze, I need this answer :(
    8·1 answer
  • EDI, ________, smart cards, and digital certificates are designed to support safe and secure online transactions.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!