Write a function called shiftRight

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 6PP: (Numerical) a. Define an array with a maximum of 20 integer values, and fill the array with numbers...
icon
Related questions
Question

1) Write a function called initializeArray that receives an array, its size, and two integers and
initializes the array with random values between the first integer and the second integer. Write another
function called printArray that receives an array and its size and prints the array elements in a column. Write
a test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive,
and then prints the array using the above functions.

2)Write a function called shiftRight that receives an array and its size and shifts the elements of the
array to the right while the last element will move to the first location. Write a test program that declares and
initializes an integer array of size 10 with random integers between 1 and 10 using initializeArray (from
question 1). Use shiftRight to shift the elements of this array to right and use printArray to print the array
before and after shift.
Here is a sample run of the program:
Original array: [2, 3, 5, 2, 2, 8, 10, 6, 5, 9]
Array after shift: [9, 2, 3, 5, 2, 2, 8, 10, 6, 5]

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Array
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