Step #4) Call the function in step 1 to print 6 elements starting at element 12. Step #5) Write a swap function that will swap two integer parameters that are passed in by reference.    Step #6) Use the swap function to swap the elements in the 100 element array at element 0 and 5. Display the first 8 elements in the array (using the function in step 1)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter1: Fundamentals Of C++ Programming
Section1.3: Preliminary Three: Software Development
Problem 7E: (Statistics) This is the formula for the standard normal deviate, z, used in statistical...
icon
Related questions
icon
Concept explainers
Question

**ATTENTION: Step #1, #2, and #3 were already solved since I posted this same passage earlier. The following is the original prompt and after that you will find the answers to Step #1, #2, and #3 that someone already solved. Step #4, #5, #6 is what remains**

---------------------------------------------------------------------------------

C++ and the focus is on Pass by Reference: 

The following steps are essentially under the same problem but in order to complete a step, the previous must be completed first. For example, Step #3 cannot be completed unless Step #1 has been conducted.

Step #1: Create a function to output the values of an integer array. You will have two parameters: the array and the number of elements to display. 

Step #2: Create an array of integers of 100 elements. File the array with the values 1 to 100

Step #3: Call the function in step 1 to print 6 elements starting at element 0

Step #4) Call the function in step 1 to print 6 elements starting at element 12.

Step #5) Write a swap function that will swap two integer parameters that are passed in by reference.   

Step #6) Use the swap function to swap the elements in the 100 element array at element 0 and 5. Display the first 8 elements in the array (using the function in step 1)

---------------------------------------------------------------------------------

** BELOW ARE THE ANSWERS TO STEPS #1, #2, #3** 

Solution Step#1: Since the function is used to output (print) the array elements, therefore, its return type is void (no return value)
 void arrayDisplay(int A[ ], int size)
{
 for(int i=0; i<size; i++)
    cout<<A[i];
}  

Solution Step#2: An array is a group of elements of same datatype using same name but different index number. The index of first element is 0 and last element is size-1. An array with 100 elements can be declared as:
int Array[100];    // here Array is an identifier name, common for all elements
for( int i=0; i<100; i++)
    Array[i]=i+1;      // fill array with 1-100

Solution Step#3: In function call, only array name is pass with size also.
arrayDisplay(Array,6);

Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
A+ Guide To It Technical Support
A+ Guide To It Technical Support
Computer Science
ISBN:
9780357108291
Author:
ANDREWS, Jean.
Publisher:
Cengage,