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
Which of the following is necessary to effectively navigate online?. A. You must be able to identify important questions. B. You
Anon25 [30]
The one that is necessary to effectively navigate online is : D. All of the above

Important questions are identified to find out the troubles that the online seeker needed, ability to communicate information is used to put the actual content, the analysis and information synthesizing is used for coding

hope this helps
6 0
3 years ago
Define decomposition
Ivanshal [37]

Answer:

the state or process of rotting

4 0
3 years ago
Ben is writing a paper for his college history class, and he wants to include some information he found on a Web site. What are
aliina [53]

Answer and Explanation:

Ben needs to cite his source of information when including information from the Web in his academic paper. A common citation method that he could use to cite his source is APA style.

When citing a website using APA style of references, you need to include the author, the title of the page or article, the date of publication, , the website name, and the URL(ususally in brackets).

4 0
3 years ago
Can someone help me out with this one? I'm not sure why my code is not working
UNO [17]

Answer:

Add this statement at the end of your steps() function

return ""

This statement will not print None at the end of steps.

Explanation:

Here is the complete function with return statement added at the end:

def steps(number):  # function steps that takes number (number of steps to print) as parameter and prints the steps specified by number

   i = 1  #assigns 1 to i

   while i < number + 1:  

       string = str(i) * 3  #multiplies value of i by 3 after converting i to string

       string1 = str(string)  # stores the step pattern to string1

       if i != 0:  # if the value of i is not equal to 0

           string1 = (i * 4*' ' + "\b" + "\b" + "\b" + "\b") + string  #set the spaces between steps

       elif i == 1:  # if value of i is equal to 1

           string1 = string  #set the string to string1

       print(string1)  # print string1

       i = i + 1  # increments i at each iteration

   return "" #this will not print None at the end of the steps and just add a an empty line instead of None.

Screenshot of the corrected program along with its output is attached.

5 0
4 years ago
1. Bluetooth
Elza [17]

Complete Question:

1. A wireless technology standard for exchanging data over short distances

2. A particular brand of mobile phone/PDA

3. A network that operates over a limited distance, usually for one or a few users

1. Bluetooth

2. PAN

3. Blackberry

Answer:

1. Bluetooth 2. Blackberry . 3. PAN

Explanation:

1. Bluetooth is a wireless technology standard, used in order to exchange data between mobile devices, like smartphones, tablets, headsets, wearables, over short distances in a one-to-one fashion (which means that it is not possible to build a network based in Bluetooth).

2. Blackberry is a brand of mobile phones/PDAs, very popular a decade ago, because it was the first one to allow mobile users to access e-mails and messages from anywhere, at any time.

3. PAN (Personal Area Network) is an ad-hoc network that it is only available for data exchange at a very short distance, within the reach of a person, i.e. a few meters as a maximum.

It is thought to allow someone to interact with his nearest environment (laptop, tablet, PDA) and it can be wireless (like Bluetooth) or wired (via USB cables).

4 0
4 years ago
Other questions:
  • Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred a
    9·1 answer
  • Certain medications can increase risk of obtaining a sunburn true or false
    12·1 answer
  • While accessing mail through the mail command interface, a user sees 5 new messages in his mailbox. Since the second message app
    13·1 answer
  • Assume each student is assigned an advisor from a department. Each classroom is assigned a classroom (class# determines Classroo
    14·1 answer
  • Employees don't have to comply with PPE requirements if they feel the PPE isn't necessary for the particular task they performed
    14·2 answers
  • The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IE
    12·1 answer
  • The process of preparing and setting up a software on a computer is called​
    15·1 answer
  • How computer network reduce the cost of computer hardware? explain with example.​
    12·2 answers
  • What are the steps in preparing a bootable USB installer?​
    11·1 answer
  • Reflection image and design
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!